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:
My code looks like this:
-(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;
}
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?
**Edit: 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.
I fixed this by ensuring that all previous requests on the webview were stopped before continuing:
[webview stopLoading];
I have absolutely no idea why I'm getting this error from Webkit, but I traced it down to trying to insert a value in a dictionary with a nil key.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With