本文主要是介绍swift之wkwebview的使用,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
import UIKit
import WebKit
class LYBBankaDetailVC: LYBBaseVC ,WKUIDelegate,WKNavigationDelegate{
var urlStr:String?
var titleStr:String?
override func viewDidLoad() {
super.viewDidLoad()
navigationItem.title=titleStr
setWKWeb()
}
func setWKWeb(){
let wkweb:WKWebView=WKWebView.init(frame: CGRect.init(x: 0, y: 0, width: WIDTH, height: HEIGHT))
view.addSubview(wkweb)
wkweb.uiDelegate=self
wkweb.navigationDelegate=self
let url:NSURL=NSURL.init(string: urlStr!)!
let request:NSURLRequest=NSURLRequest.init(url: url as URL)
wkweb.load(request as URLRequest)
}
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
}
func webView(_ webView: WKWebView, didFail navigation: WKNavigation!, withError error: Error) {
}
==========
这篇关于swift之wkwebview的使用的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!