I am using the delegate method shouldStartLoadWithRequest
to catch link clicks and handle specific cases inside my app instead of allowing the webView
Check out if you nullify delegate property of UIWebView in its controller dealloc method (of course if this controller is webview's delegate). Like this:
- (void) viewDidLoad
{
webView.delegate = self;
}
- (void) dealloc
{
webView.delegate = nil;
}
From the Apple docs on the delegate property:
Important. Before releasing an instance of UIWebView for which you have set a delegate, you must first set its delegate property to nil. This can be done, for example, in your dealloc method.
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.
Yet another cause for this error can be the fact that Autolayout is accidentally left enabled in the viewcontroller containing the webview. This happened to me while testing on iOS5.
I got a similar error:
***WebKit discarded an uncaught exception in the webView:decidePolicyForNavigationAction:frame:decisionListner: delegate: - [UIPopoverController dealloc] reached while popover is still visible.
The problem seems to be caused by the following code:
UIPopoverController *pc = [[UIPopoverController alloc] initWithContentViewController:vc];
[pc presentPopoverFromRect:frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionLeft animated:YES];
Apparently, pc is being deallocated when the routine exits. I changed the code to make pc a property and WebKit stopped complaining.
I fixed this by ensuring that all previous requests on the webview were stopped before continuing:
[webview stopLoading];