我在UIWebView
中有一个UITableViewCell
,当我尝试在nil
方法中将网络视图的委托设置为dealloc
时,应用会随机崩溃。你能告诉我怎么解决这个问题吗?
以下是我的dealloc
方法的代码:
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
@try {
NSLog(@"Dealloc");
for (int i=0;i<[arr_searchdocket count];i++) {
cell_webview *cell=[tbl_search cellForRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:0]];
[cell.webview stopLoading];
cell.webview.delegate=nil;
NSLog(@"Dealloc row %d",i);
}
[self.view endEditing:YES];
[tbl_search setContentOffset:CGPointZero animated:NO];
tbl_search.dataSource=nil;
tbl_search.delegate=nil;
tbl_search=nil;
self.navigationController.delegate=nil;
}
@catch (NSException *exception) {
}
}
以下是我收到的错误的堆栈跟踪:
Thread : Crashed: com.apple.main-thread
0 libobjc.A.dylib 0x38282f76 objc_msgSend + 21
1 UIKit 0x2d3603ed -[_UIWebViewScrollViewDelegateForwarder forwardInvocation:] + 144
2 CoreFoundation 0x29afe371 ___forwarding___ + 352
3 CoreFoundation 0x29a2d9d8 _CF_forwarding_prep_0 + 24
4 UIKit 0x2d1a575d -[UIScrollView _getDelegateZoomView] + 84
5 UIKit 0x2d1a5699 -[UIScrollView _zoomScaleFromPresentationLayer:] + 24
6 UIKit 0x2d1a5655 -[UIWebDocumentView _zoomedDocumentScale] + 60
7 UIKit 0x2d1a51a5 -[UIWebDocumentView _layoutRectForFixedPositionObjects] + 104
8 UIKit 0x2d1a5007 -[UIWebDocumentView _updateFixedPositionedObjectsLayoutRectUsingWebThread:synchronize:] + 38
9 UIKit 0x2d1a7445 -[UIWebDocumentView _updateFixedPositioningObjectsLayoutAfterScroll] + 28
10 UIKit 0x2d1a7421 -[UIWebBrowserView _updateFixedPositioningObjectsLayoutAfterScroll] + 56
11 CoreFoundation 0x29ab30c5 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
12 CoreFoundation 0x29a0ccbd _CFXNotificationPost + 1800
13 Foundation 0x2a76f3a1 -[NSNotificationCenter postNotificationName:object:userInfo:] + 76
14 UIKit 0x2d7c16c7 -[UIInputWindowController postEndNotifications:withInfo:] + 554
15 UIKit 0x2d7bff15 -[UIInputWindowController performWithSafeTransitionFrames:] + 136
16 UIKit 0x2d7c3019 __77-[UIInputWindowController moveFromPlacement:toPlacement:starting:completion:]_block_invoke644 + 428
17 UIKit 0x2d18f8e1 -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 308
18 UIKit 0x2d18f4f9 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 184
19 UIKit 0x2d18f40f -[UIViewAnimationState animationDidStop:finished:] + 70
20 QuartzCore 0x2cb74fe7 CA::Layer::run_animation_callbacks(void*) + 234
21 libdispatch.dylib 0x38806c6f _dispatch_client_callout + 22
22 libdispatch.dylib 0x38812553 _dispatch_main_queue_callback_4CF$VARIANT$mp + 1322
23 CoreFoundation 0x29ac0889 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 8
24 CoreFoundation 0x29abefa9 __CFRunLoopRun + 1512
25 CoreFoundation 0x29a0a9a1 CFRunLoopRunSpecific + 476
26 CoreFoundation 0x29a0a7b3 CFRunLoopRunInMode + 106
27 GraphicsServices 0x313a31a9 GSEventRunModal + 136
28 UIKit 0x2d1bb635 UIApplicationMain + 1440
29 TaskTower 0xc4379 main (main.m:14)
30 libdyld.dylib 0x38844aaf start + 2