Thread : Crashed: com.apple.main-thread 0 libobjc.A.dylib 0x34217f46 objc_msgSend + 5 1 UIKit 0x29a2d5a3 -[UIWebView webView:decidePolicyForNavigationAction:request:frame:decisionListener:] + 182 2 CoreFoundation 0x2630cad4 __invoking___ + 68 3 CoreFoundation 0x26239645 -[NSInvocation invoke] + 300 4 CoreFoundation 0x2623d0c7 -[NSInvocation invokeWithTarget:] + 50 5 WebKitLegacy 0x326d9261 -[_WebSafeForwarder forwardInvocation:] + 224 6 CoreFoundation 0x2630b62f ___forwarding___ + 354 7 CoreFoundation 0x2623d008 _CF_forwarding_prep_0 + 24 8 CoreFoundation 0x2630cad4 __invoking___ + 68 9 CoreFoundation 0x26239645 -[NSInvocation invoke] + 300 10 WebCore 0x31c02729 HandleDelegateSource(void*) + 100 11 CoreFoundation 0x262cefbf __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 14 12 CoreFoundation 0x262ce461 __CFRunLoopDoSources0 + 364 13 CoreFoundation 0x262cca35 __CFRunLoopRun + 772 14 CoreFoundation 0x2621a3b1 CFRunLoopRunSpecific + 476 15 CoreFoundation 0x2621a1c3 CFRunLoopRunInMode + 106 16 GraphicsServices 0x2d801201 GSEventRunModal + 136 17 UIKit 0x2988443d UIApplicationMain + 1440 18 abc 0x0030dcd7 main (main.m:14)
我可以理解它在webview委托上发生了一些回调并且发生了不好的过量,所以为了纠正这个问题,我通过
[self.webview stopLoading]; self.webview.delegate =nil;
在所有课程中,我可以看到这个崩溃.你能告诉我可能出现的问题以及纠正这种情况的方法吗?
解决方法
>用户将看到一个带有UIWebView的屏幕
> UIViewController在委托网页开始下载时设置self
>用户退出屏幕
> UIViewController获取解除分配UIWebView完成加载并发送我已完成加载消息到其委托
要么
当webview对象不再是.i.e悬挂指针效果时,会调用其他一些委托方法
1.始终确保在离开视图之前停止加载webView并删除委托
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,in yourdealloc
method
// If ARC is used - (void)dealloc { [_webView setDelegate:nil]; [_webView stopLoading]; } // If ARC is not used - (void)dealloc { [webView setDelegate:nil]; [webView stopLoading]; [webView release]; [super dealloc]; } // ARC - Before iOS6 as its deprecated from it. - (void)viewWillUnload { [webView setDelegate:nil]; [webView stopLoading]; }
2.确保你在viewWillDisappear中没有stopLoading和setDelegate为nil
if the ViewController is a child of a another ViewController,u can
trigger the removal of the ViewController’s view from the parent
ViewController’s view with an animation. At the same time,u can
remove the ViewController from its parent andnil
out its reference.
at this pointViewController
will benil
andviewWillDisappear
will never be called,meaning the WebView delegate will never be
cleaned upUse
dealloc
and ensure that your WebView is always cleaned up.
3.确保在没有动画的情况下将webview子视图的ContentOffset设置为CGPointZero
In iPad in some versions while webview is scrolling if you close the parent
viewcontroller without setting ContentOffset toCGPointZero
this
kind of problems will come
for (id subview in webView.subviews){ if ([[subview class] isSubclassOfClass: [UIScrollView class]]){ [subview setContentOffset:CGPointZero animated:NO]; } }
希望这会有所帮助.随意问你的疑惑.
4.一般来说,您不应该在UIScrollView对象中嵌入UIWebView对象.如果这样做,可能会导致意外行为,因为两个对象的触摸事件可能混淆和错误处理.