在某些版本的 iPad 中,如果关闭父级,则 webview 会滚动没有将 ContentOffset 设置为 CGPointZero 的视图控制器各种问题都会来所以最好在关闭它之前调用父视图控制器中的以下代码 for (id subview in webView.subviews){if ([[subview class] isSubclassOfClass: [UIScrollView class]]){[子视图 setContentOffset:CGPointZero 动画:NO];}}希望这会有所帮助.如有疑问,请随时提出.4. 一般而言,您不应该在 UIScrollView 对象中embed UIWebView 对象.如果这样做,可能会导致意外行为,因为这两个对象的触摸事件可能会混淆并错误处理.这是参考I have a situation where I am trying to resolve these Crashlytics issues and I have this crash logThread : Crashed: com.apple.main-thread0 libobjc.A.dylib 0x34217f46 objc_msgSend + 51 UIKit 0x29a2d5a3 -[UIWebView webView:decidePolicyForNavigationAction:request:frame:decisionListener:] + 1822 CoreFoundation 0x2630cad4 __invoking___ + 683 CoreFoundation 0x26239645 -[NSInvocation invoke] + 3004 CoreFoundation 0x2623d0c7 -[NSInvocation invokeWithTarget:] + 505 WebKitLegacy 0x326d9261 -[_WebSafeForwarder forwardInvocation:] + 2246 CoreFoundation 0x2630b62f ___forwarding___ + 3547 CoreFoundation 0x2623d008 _CF_forwarding_prep_0 + 248 CoreFoundation 0x2630cad4 __invoking___ + 689 CoreFoundation 0x26239645 -[NSInvocation invoke] + 30010 WebCore 0x31c02729 HandleDelegateSource(void*) + 10011 CoreFoundation 0x262cefbf __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 1412 CoreFoundation 0x262ce461 __CFRunLoopDoSources0 + 36413 CoreFoundation 0x262cca35 __CFRunLoopRun + 77214 CoreFoundation 0x2621a3b1 CFRunLoopRunSpecific + 47615 CoreFoundation 0x2621a1c3 CFRunLoopRunInMode + 10616 GraphicsServices 0x2d801201 GSEventRunModal + 13617 UIKit 0x2988443d UIApplicationMain + 144018 abc 0x0030dcd7 main (main.m:14)I can understand that its some callback on webview delegate and bad excess has occurred, so to rectify this I handled the delegates via[self.webview stopLoading];self.webview.delegate =nil;in all the classes, yet I can see this crash. Can you enlighten me what's possibly going wrong and some approach to rectify this? 解决方案 The following might be the case hereThe user is presented a screen with UIWebViewThe UIViewController sets self as the delegate Web page starts downloadingThe User quits screenUIViewController gets deallocated UIWebView finishes loading and sends I am finished loading message to its delegateorsome other delegate method gets called when the webview object is no more.i.e dangling pointer effect1.Always make sure you stop loading the webView and remove the delegate before leaving the viewHere is the reference // 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.Make sure you are not stopLoading and setDelegate to nil in viewWillDisappear 3.Make sure you set the ContentOffset of the subviews of webview to CGPointZero without animation so its better to you call the following code of in parent viewcontroller before closing it for (id subview in webView.subviews){ if ([[subview class] isSubclassOfClass: [UIScrollView class]]){ [subview setContentOffset:CGPointZero animated:NO]; } }Hope this helps.Feel free to ask your doubts.4.Generally speaking You should not embed UIWebView objects in UIScrollView objects. If you do so, unexpected behavior can result because touch events for the two objects can be mixed up and wrongly handled.Here is the reference 这篇关于ios:EXC_BAD_ACCESS 用于 Webview 委托的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!