我已经查看了这个问题的很多答案,但它们现在似乎已经过时了,没有一个解决方案对我有用,只是给出了很多错误。
我刚刚开始使用 xcode 和应用程序,并将本地 html 文件“index.html”加载到 WKWebView 中。这很好,加载正常,显示正常,但是我在页面上有一些 tel: 链接不起作用,我点击它们什么也没有。我正在为我的 html 文件使用 fraework7 并添加了“外部”类,它在 safari 等中工作。
更新:使用下面的代码,我可以点击一个链接,它会尝试调用,但会给出一个致命的错误
import UIKit
import WebKit
class ViewController: UIViewController, WKNavigationDelegate{
@IBOutlet weak var webview: WKWebView!
override func viewDidLoad() {
webview.navigationDelegate = self
super.viewDidLoad()
let htmlpath = Bundle.main.path(forResource: "index", ofType: "html")
let url = URL(fileURLWithPath: htmlpath!)
let request = URLRequest(url: url)
webview.load(request)
webview.scrollView.bounces = false
webview.configuration.dataDetectorTypes = .phoneNumber
// Do any additional setup after loading the view, typically from a nib.
}
func webView(_ webView: WKWebView, …Run Code Online (Sandbox Code Playgroud)