I have a UIWebView I\'m using to show several small PDF\'s. The user selects a news article from a table and then the article(PDF) is loaded in a UIWebView on the same screen.
I'm seeing something similar - both while freeing a webview after loading a PDF or while loading html after loading a PDF. It appears to be rdar://10431759 (see http://openradar.appspot.com/10431759 ). I don't have a way to work around it. I can reproduce it by loading a pdf and then loading the html string @""
, so it doesn't appear to be a delegate issue.
If you type "bt" into the gdb console, you may get the real stacktrace, including:
#0 0x37ccd1c8 in objc_exception_throw ()
#1 0x381817b8 in +[NSException raise:format:arguments:] ()
#2 0x381817b8 in +[NSException raise:format:arguments:] ()
#3 0x381817da in +[NSException raise:format:] ()
#4 0x35462628 in -[NSObject(NSKeyValueObserverRegistration) _removeObserver:forProperty:] ()
#5 0x35462296 in -[NSObject(NSKeyValueObserverRegistration) removeObserver:forKeyPath:] ()
#6 0x31fc3448 in -[UIWebPDFView _removeBackgroundImageObserverIfNeeded:] ()
#7 0x31fc36a8 in -[UIWebPDFView dealloc] ()
#8 0x37cc90c4 in _objc_rootRelease ()
#9 0x31dd2614 in -[UIWebPDFViewHandler clearAllViews] ()
#10 0x31d76708 in -[UIWebPDFViewHandler _replacePDFViewIfPresentWithWebDocView:] ()
#11 0x31d766a6 in -[UIWebPDFViewHandler _removePDFViewIfWebDocViewIsNotPDF:] ()
#12 0x31d76644 in -[UIWebBrowserView webView:didFirstVisuallyNonEmptyLayoutInFrame:] ()
When debugging on the device, you can type "frame 0" and "po $r0" to see the exception message: (I think it's "po $eax" in the simulator.)
(gdb) frame 0
#0 0x37ccd1c8 in objc_exception_throw ()
(gdb) po $r0
Cannot remove an observer for the key path "backgroundImage" from because it is not registered as an observer.
Edit: This problem only seems to occur when I have "Break on throw" turned on for Objective-C exceptions.