objective-c - iOS 开发中 WKWebView 的使用问题拦截跳转
PHP中文网
PHP中文网 2017-04-18 09:57:20
0
2
1238
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler { 请问这里的 webView.URL 和 navigationAction.request.URL 有什么区别? } - (void)webView:(WKWebView *)webView decidePolicyForNavigationResponse:(WKNavigationResponse *)navigationResponse decisionHandler:(void (^)(WKNavigationResponsePolicy))decisionHandler { 请问这里的 webView.URL 和 navigationAction.request.URL 有什么区别? }

问题:
1.上面代码块里面的问题 webView.URL 和 navigationAction.request.URL 有什么区别?
2.当我第一次加载一个网页的时候,上面的代理方法为什么会被调用多次?
3.如果我想拦截网页的跳转链接,希望通过 push 打开一个页面重新展示一个 webview,最好是在哪个代理方法里拦截? 遇到重定向问题怎么破?

PHP中文网
PHP中文网

认证0级讲师

全部回覆 (2)
Ty80

調多次 是不是因為url有重定向

    阿神

    你可以列印出來看看他們的數值,看看跳轉網頁的時候是在哪裡列印的。
    文檔裡有關於這兩個代理的說明。

    /*! @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;
      最新下載
      更多>
      網站特效
      網站源碼
      網站素材
      前端模板
      關於我們 免責聲明 Sitemap
      PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!