func webVIEwDIDFinishLoad(_ webVIEw : WKWebVIEw) { UIApplication.shared.isNetworkActivityIndicatorVisible = false if (webVIEw.request?.url!.absoluteString)!.range(of: ".pdf") != nil { pdfBackbutton.isHIDden = false } else { pdfBackbutton.isHIDden = true}}解决方法 将“WebKit”框架添加到您的班级.
overrIDe func vIEwDIDLoad() { super.vIEwDIDLoad() let myWebVIEw:WKWebVIEw = WKWebVIEw(frame: CGRect(x: 0.0,y: 0.0,wIDth: UIScreen.main.bounds.wIDth,height: UIScreen.main.bounds.height)) myWebVIEw.navigationDelegate = self; let url = URL(string: "https://www.Apple.com")! myWebVIEw.load(URLRequest(url: url)) self.vIEw.addSubvIEw(myWebVIEw)}
然后实现WKNavigationDelegate方法
func webVIEw(_ webVIEw: WKWebVIEw,dIDFinish navigation: WKNavigation!) { UIApplication.shared.isNetworkActivityIndicatorVisible = false let url = webVIEw.url print(url as Any) // this will print url address as option fIEld if url?.absoluteString.range(of: ".pdf") != nil { pdfBackbutton.isHIDden = false print("pdf contain") } else { pdfBackbutton.isHIDden = true print("No pdf Contain") } }
希望对你有帮助!
总结以上是内存溢出为你收集整理的ios – WKWebView中的webViewDidFinishLoad全部内容,希望文章能够帮你解决ios – WKWebView中的webViewDidFinishLoad所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)