我正在尝试通过网络视图加载URL。
import UIKit
class ViewController: UIViewController, WKNavigationDelegate{
@IBOutlet weak var webView: WKWebView!
@IBOutlet weak var statusLabel: UILabel!
@IBOutlet weak var activityIndicator: UIActivityIndicatorView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
@IBAction func loadButtonPressed(_ sender: UIButton) {
if let url = URL(string: "https://www.google.com") {
let urlRequest = URLRequest(url: url)
webView.load(URLRequest)
}
}
}
它显示Use of undeclared type 'WKNavigationDelegate'
。我找不到问题所在。我该如何解决?我想念什么吗?
答案 0 :(得分:2)
好,我修复它。
我必须先做import WebKit