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.