【发布时间】:2017-03-16 17:37:26
【问题描述】:
我正在编写一个可重用的 UIWebView 控制器,并希望在使用委托 shouldStartLoadWith 函数时从该控制器下降并覆盖它,但我不知道该怎么做。
在我的可重复使用的UiWebView 控制器中,我有这个。
func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebViewNavigationType) -> Bool {
let docURLStr = request.mainDocumentURL!.absoluteString
if docURLStr.contains("login") {
loadLoginView()
return false
}
然后在我的子类中,我想执行以下操作,但我想同时使用这两个功能。我该怎么做?
override func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebViewNavigationType) -> Bool {
let docUrl = request.url!.absoluteString
if String(describing: docUrl).range(of: "some string in the url") != nil{
return true
} else {
return false
}
}
【问题讨论】:
标签: swift3 uiwebview uiwebviewdelegate