【发布时间】:2016-12-19 19:44:35
【问题描述】:
由于某些 WKWebView 不适合我的原因,我在我的应用程序中使用 UIWebView。
解释一下,我刚刚完成了我的应用程序转换为 Swift3(是 2.2)和我的 shouldStartLoadWith 函数没有收到 JS 事件。
如果我在转换之前运行我以前的构建 - 一切都很完美。
我的代码如下所示:
func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebViewNavigationType) -> Bool {
let url:URL = request.url!
if (url.scheme == "something"){
if (url.host != nil){
var properString = url.absoluteString.removingPercentEncoding!
properString = properString.replacingOccurrences(of: "something://", with: "")
performJSFunction(message: properString)
}
return false;
}
return true
}
注意:服务器端/html 页面没有任何变化。
【问题讨论】:
-
你找到解决办法了吗?
-
是的,看看我的回答
标签: javascript uiwebview swift3 xcode8 uiwebviewdelegate