从UIWebview迁移到WKWebview

时间:2019-10-03 09:14:59

标签: ios swift uiwebview wkwebview

我需要从UIWebView迁移到WKWebView,但我不能。有人知道吗?

importUIKit

class ViewController: UIViewController {

let URL:String = "https://google.com"

@IBOutlet weak var webView: UIWebView!

override func viewDidLoad() {
    super.viewDidLoad()
    let url = NSURL (string: URL);
    let requestObj = NSURLRequest(url: url! as URL);
    webView.loadRequest(requestObj as URLRequest);
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

2 个答案:

答案 0 :(得分:0)

您只需要更改,将UIWebView的{​​{1}}添加WKWebView并将Outlet的类名称更改为WKWebView,还将import WebKit的{​​{1} }}

loadRequest

答案 1 :(得分:0)

新的API将相同

FeignContext-xxx