我必须在UIWebView或WKWebView中使用http协议加载html文件。这是我使用WKWebView的代码:
import UIKit
import WebKit
class ViewController: UIViewController,WKUIDelegate {
var webView: WKWebView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let webConfiguration = WKWebViewConfiguration()
webView = WKWebView(frame: self.view.frame, configuration: webConfiguration)
webView.uiDelegate = self
let path = URL(fileURLWithPath: "index.html")
let myURL = path
let myRequest = URLRequest(url: myURL)
webView.load(myRequest)
self.view.addSubview(webView)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
是否可以从原生包中解析http protocal?