objective-c - iOS 開(kāi)發(fā)中 WKWebView 的使用問(wèn)題攔截跳轉(zhuǎn)
問(wèn)題描述
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler { 請(qǐng)問(wèn)這里的 webView.URL 和 navigationAction.request.URL 有什么區(qū)別? }- (void)webView:(WKWebView *)webView decidePolicyForNavigationResponse:(WKNavigationResponse *)navigationResponse decisionHandler:(void (^)(WKNavigationResponsePolicy))decisionHandler {請(qǐng)問(wèn)這里的 webView.URL 和 navigationAction.request.URL 有什么區(qū)別?}
問(wèn)題:1.上面代碼塊里面的問(wèn)題 webView.URL 和 navigationAction.request.URL 有什么區(qū)別?2.當(dāng)我第一次加載一個(gè)網(wǎng)頁(yè)的時(shí)候,上面的代理方法為什么會(huì)被調(diào)用多次?3.如果我想攔截網(wǎng)頁(yè)的跳轉(zhuǎn)鏈接,希望通過(guò) push 打開(kāi)一個(gè)頁(yè)面重新展示一個(gè) webview,最好是在哪個(gè)代理方法里攔截? 遇到重定向問(wèn)題怎么破?
問(wèn)題解答
回答1:調(diào)多次 是不是因?yàn)閡rl有重定向
回答2:你可以打印出來(lái)看看他們的值,看看跳轉(zhuǎn)網(wǎng)頁(yè)的時(shí)候是在哪里打印的。文檔里有關(guān)于這兩個(gè)代理的說(shuō)明。
/*! @abstract Decides whether to allow or cancel a navigation. @param webView The web view invoking the delegate method. @param navigationAction Descriptive information about the action triggering the navigation request. @param decisionHandler The decision handler to call to allow or cancel the navigation. The argument is one of the constants of the enumerated type WKNavigationActionPolicy. @discussion If you do not implement this method, the web view will load the request or, if appropriate, forward it to another application. */- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler;/*! @abstract Decides whether to allow or cancel a navigation after its response is known. @param webView The web view invoking the delegate method. @param navigationResponse Descriptive information about the navigation response. @param decisionHandler The decision handler to call to allow or cancel the navigation. The argument is one of the constants of the enumerated type WKNavigationResponsePolicy. @discussion If you do not implement this method, the web view will allow the response, if the web view can show it. */- (void)webView:(WKWebView *)webView decidePolicyForNavigationResponse:(WKNavigationResponse *)navigationResponse decisionHandler:(void (^)(WKNavigationResponsePolicy))decisionHandler;
相關(guān)文章:
1. javascript - js 修改表格元素的,可以用DOM操作實(shí)現(xiàn)嗎?2. python中def定義的函數(shù)加括號(hào)和不加括號(hào)的區(qū)別?3. 用tp5框架寫sql語(yǔ)句4. javascript - 請(qǐng)教移動(dòng)端從詳情頁(yè)返回到列表頁(yè)原來(lái)位置的問(wèn)題?5. python - xpath提取網(wǎng)頁(yè)路徑?jīng)]問(wèn)題,但是缺失內(nèi)容?6. javascript - js一個(gè)call和apply的問(wèn)題?7. 跪求解答關(guān)于emmetc插件生效的問(wèn)題8. javascript - js setTimeout在雙重for循環(huán)中如何使用?9. 點(diǎn)擊頁(yè)面就自動(dòng)輸入到mysql.求解10. javascript - 關(guān)于微信公眾號(hào)開(kāi)發(fā)的一個(gè)trouble!
