xcode swift UIWebview 禁止打开以 https://m 开头的链接
xcode swift UIWebview disable links to open that start with https://m
大家好,我最初加载的是 https://www.etcccc link but its a video and it has an overlay image that if clicked it will navigate to a https://m.etccccc,我只需要将以 "m" 而非 "www" 开头的网址限制为 return 错误在 shouldstartloadrequest 但我有问题。感谢所有帮助
webview 委托 shouldStartLoadWith 请求是限制 url.try this
的最佳位置
func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebViewNavigationType) -> Bool {
if request.url?.host?.hasPrefix("m") == true{
return false
}
else{
return true
}
}
大家好,我最初加载的是 https://www.etcccc link but its a video and it has an overlay image that if clicked it will navigate to a https://m.etccccc,我只需要将以 "m" 而非 "www" 开头的网址限制为 return 错误在 shouldstartloadrequest 但我有问题。感谢所有帮助
webview 委托 shouldStartLoadWith 请求是限制 url.try this
的最佳位置func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebViewNavigationType) -> Bool {
if request.url?.host?.hasPrefix("m") == true{
return false
}
else{
return true
}
}