相关疑难解决方法(0)

检测何时在WKWebView中单击链接

如何检测WKWebView中单击链接的时间?我在UIWebView中寻找相当于此的东西.

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
    if(navigationType == UIWebViewNavigationTypeLinkClicked)
    {

    }
    return YES;
}
Run Code Online (Sandbox Code Playgroud)

我试过这个,WKNavigationDelegateWKNavigationTypeOther即使点击链接,我也只能得到所有请求.

- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler
{
    if(navigationAction.navigationType == WKNavigationTypeLinkActivated)
    {

    }
    decisionHandler(WKNavigationActionPolicyAllow);
}
Run Code Online (Sandbox Code Playgroud)

objective-c ios wkwebview

10
推荐指数
1
解决办法
1万
查看次数

标签 统计

ios ×1

objective-c ×1

wkwebview ×1