我在使用基于 WKWebView 的 iOS 应用程序时遇到了挑战:页面上的某些链接不可点击。当我使用 Safari 视图控制器尝试它们时,它们可以工作。请任何人都可以帮助我吗?
这是我的源代码:
import UIKit
import WebKit
class ViewController: UIViewController, WKUIDelegate, WKNavigationDelegate {
var webView: WKWebView! //declare the webview has to be optional
var activityIndicator: UIActivityIndicatorView!
override func loadView() {
super.loadView()
let webConfiguration = WKWebViewConfiguration()
webView = WKWebView(frame: .zero, configuration: webConfiguration)
webView.uiDelegate = self
webView.navigationDelegate = self
view = webView
}
override func viewDidLoad() {
super.viewDidLoad()
let myURL = URL(string: "https://stolenandfound.com/")
let myRequest = URLRequest(url: myURL!)
webView.load(myRequest)
activityIndicator = UIActivityIndicatorView() //declare the progress indicator
activityIndicator.frame …Run Code Online (Sandbox Code Playgroud)