问题描述
我刚刚从iTunes Connect下载了其中一个iPhone应用程序的崩溃报告。最常见的崩溃具有如下所示的踪迹:
I just downloaded the crash reports for one of my iPhone apps from iTunes Connect. The most common crash has a trace like the following:
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0xa1b1c1db
Crashed Thread: 0
Thread 0 Crashed:
0 libobjc.A.dylib 0x3030e6f4 objc_msgSend + 16
1 UIKit 0x30ebebee -[UIWebView webView:resource:didFinishLoadingFromDataSource:]
2 UIKit 0x30ebe5ca -[UIWebViewWebViewDelegate webView:resource:didFinishLoadingFromDataSource:]
3 CoreFoundation 0x32b73b5c __invoking___ + 60
4 CoreFoundation 0x32bc67be -[NSInvocation invoke]
5 WebCore 0x320baa86 HandleDelegateSource
6 CoreFoundation 0x32bb8a96 CFRunLoopRunSpecific
7 CoreFoundation 0x32bb8356 CFRunLoopRunInMode
8 GraphicsServices 0x30544cd4 GSEventRunModal
9 GraphicsServices 0x30544d80 GSEventRun
10 UIKit 0x30d2c768 -[UIApplication _run]
11 UIKit 0x30d2b46c UIApplicationMain
我大约80%的人确定这是UIWebView内部的问题,而我无法解决的问题。是否有人对如何缩小此问题的范围有任何建议,以帮助确定是OS和UIWebView的问题,还是我可以在代码中解决并解决的问题?
I'm about 80% sure this is an issue internal to UIWebView and outside the scope of what I can address. Does anyone have any suggestions on how to narrow down this issue to help identify whether it's an issue with the OS and UIWebView, or an issue that I can fix and address in my code? Thanks in advance.
更新:有问题的UIWebView处于视图中,当用户单击相应导航控制器的后退按钮时,该视图将被释放。接受的解决方案似乎可以很好地解释为什么会发生此错误。
UPDATE: The UIWebView in question is in a view that gets released when the user hits the back button of the corresponding navigation controller. The accepted solution seems to provide a good explanation for why this error is occurring.
在建议的解决方案之前:
Before suggested solution:
- (void)dealloc {
[webView release];
[super dealloc];
}
建议的解决方案后:
- (void)dealloc {
webView.delegate = nil;
[webView stopLoading];
[webView release];
[super dealloc];
}
推荐答案
:
- 用户使用
UIWebView
进入屏幕。UIViewController
将self
设置为委托 - 网页开始下载
- 用户退出屏幕
3a。UIViewController
被释放 -
UIWebView
完成加载并发送我完成消息给它的代表...
- User enters screen with
UIWebView
. TheUIViewController
setsself
as the delegate - Web page starts downloading
- User exits screen
3a.UIViewController
gets deallocated UIWebView
finishes loading and sends "I finished" message to its delegate...
您需要停止加载 UIWebView
它的页面并将其委托设置为nil,然后再取消分配该委托。
You need to stop the UIWebView
from loading its page and sets its delegate to nil before you deallocate the delegate.
这篇关于UIWebView中的EXC_BAD_ACCESS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!