iOS 5 UIWebview Delegate: WebKit discarded an uncaught exception in the webView:decidePolicyForNavigationAction(iOS 5 UIWebview 委托:WebKit 丢弃了 webView 中未捕获的异常:decidePolicyForNavigationAction)
问题描述
我正在使用委托方法 shouldStartLoadWithRequest
来捕获链接点击并处理我的应用程序内的特定情况,而不是允许 webView
导航到链接.在这段代码中,我试图将一个新的 ViewController
推送到堆栈上.在尝试推送视图后,我立即在控制台中收到以下消息崩溃:
I am using the delegate method shouldStartLoadWithRequest
to catch link clicks and handle specific cases inside my app instead of allowing the webView
to navigate to the link. In this code, I am attempting to push a new ViewController
onto the stack. Immediately after the attempt to push the view, I get a crash with the following message in my console:
WebKit discarded an uncaught exception in the webView:decidePolicyForNavigationAction:request:frame:decisionListener: delegate:
我的代码如下所示:
-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
if(decision logic){
MyViewController *vc = [[MyViewController alloc] init];
[self.navigationController pushViewController:vc animated:YES];
[vc release];
return NO;
}
return YES;
}
我也尝试过使用模式而不是推送新的 viewController
.我得到相同的结果.我应该在这里处理任何其他情况吗?
I have also tried using a modal instead of pushing a new viewController
. I get the same result. Is there any other scenarios I should be handling here?
**刚想到这个.我试图推送的视图包含另一个 UIWebView
.我应该在过渡之前对第一个 webView
做些什么吗?我只是测试推送一个不包含 webView
的不同视图控制器,它工作正常.
** Just thought of this. The view I'm trying to push contains another UIWebView
. Should I be doing something to the first webView
before transitioning? I just testing pushing a different view controller that doesn't contain a webView
and it worked fine.
推荐答案
我通过确保在继续之前停止 webview 上的所有先前请求来解决此问题:
I fixed this by ensuring that all previous requests on the webview were stopped before continuing:
[webview stopLoading];
这篇关于iOS 5 UIWebview 委托:WebKit 丢弃了 webView 中未捕获的异常:decidePolicyForNavigationAction的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:iOS 5 UIWebview 委托:WebKit 丢弃了 webView 中未捕获的异常:decidePolicyForNavigationAction
基础教程推荐
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01