macos webView:decidePolicyForNavigationAction:请求:frame:decisionListener:多次调用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4301455/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 07:23:08  来源:igfitidea点击:

webView: decidePolicyForNavigationAction: request: frame: decisionListener: called multiple times

objective-ccocoamacoswebkit

提问by Sid

I am using the following code to load a url in my webview but it is called multiple times and my application crashes.

我正在使用以下代码在我的 web 视图中加载一个 url,但它被多次调用并且我的应用程序崩溃了。


- (void)webView:(WebView *)webView decidePolicyForNavigationAction:(NSDictionary *)actionInformation request:(NSURLRequest *)request frame:(WebFrame *)frame decisionListener:(id )listener
{

    [[myWebView mainFrame] loadRequest:request];
}


回答by Piotr Byzia

Use [listener use]instead, to tell your webview to handle clicked URL.

[listener use]改为使用,告诉您的 webview 处理点击的 URL。