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
- 网上有没有好的 UIScrollView 教程? 2022-01-01
- UITextView 内容插图 2022-01-01
- Xcode 7.3 中带有 UILabel 的 UIStackView 2022-01-01
- SetOnItemSelectedListener上的微调程序错误 2022-01-01
- 类似于 Mail.app 的 iPad 模态视图控制器? 2022-01-01
- URL编码Swift iOS 2022-01-01
- GPS状态的广播接收器? 2022-01-01
- 在 Iphone SDK 的导航栏上添加多个按钮 2022-01-01
- 使用自动布局向 UIScrollView 添加动态大小的视图 2022-01-01
- 如何在 iPhone 模拟器中重置 NSUserDefaults 数据? 2022-01-01