3

I have a uitableviewcontroller and im loading a uiwebview as viewForFooterInSection for the tableview

This webview has some html content being loaded. The app crashes whenever I try to do

[self.tableView beginUpdates];
    [self.tableView reloadSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationTop];
    [self.tableView endUpdates];

Crash log attached

Incident Identifier: DA08DEDA-3566-4A56-938A-57F4BCDF64F1
CrashReporter Key:   ef8a5122f6b5431e4b29802596ec279644f97bd4
Hardware Model:      iPod4,1
Process:         sample [955]
Path:            /var/mobile/Applications/A0B6D2C6-AA93-4D24-9C7F-666B8C7F94B4/sample.app/sample
Identifier:      sample
Version:         ??? (???)
Code Type:       ARM (Native)
Parent Process:  launchd [1]

Date/Time:       2012-07-24 13:07:10.396 +0530
OS Version:      iPhone OS 4.3.5 (8L1)
Report Version:  104

Exception Type:  EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000c
Crashed Thread:  0

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   WebCore                         0x35fbc900 WebCore::TileCache::doLayoutTiles() + 24
1   WebCore                         0x3609bed8 -[TileHostLayer renderInContext:] + 28
2   QuartzCore                      0x336cc948 -[CALayer _renderSublayersInContext:] + 220
3   QuartzCore                      0x336cbada -[CALayer renderInContext:] + 1086
4   QuartzCore                      0x336cc948 -[CALayer _renderSublayersInContext:] + 220
5   QuartzCore                      0x336cbada -[CALayer renderInContext:] + 1086
6   QuartzCore                      0x336cc948 -[CALayer _renderSublayersInContext:] + 220
7   QuartzCore                      0x336cbada -[CALayer renderInContext:] + 1086
8   QuartzCore                      0x336cc948 -[CALayer _renderSublayersInContext:] + 220
9   QuartzCore                      0x336cbada -[CALayer renderInContext:] + 1086
10  QuartzCore                      0x336cc948 -[CALayer _renderSublayersInContext:] + 220
11  QuartzCore                      0x336cbada -[CALayer renderInContext:] + 1086
12  UIKit                           0x35b6b2dc -[_UITableViewUpdateSupport(Private) _imageViewForView:] + 68
13  UIKit                           0x35b6a66a -[_UITableViewUpdateSupport(Private) _setupDeleteAnimationForFooterInSection:withTargetRect:forUpdateItem:] + 370
14  UIKit                           0x35a7f91a -[_UITableViewUpdateSupport(Private) _setupAnimationsForDeletedHeadersAndFooters] + 1862
15  UIKit                           0x35a78be6 -[_UITableViewUpdateSupport initWithTableView:updateItems:oldRowData:newRowData:oldRowRange:newRowRange:context:] + 398
16  UIKit                           0x35a77dba -[UITableView(_UITableViewPrivate) _updateWithItems:withOldRowData:oldRowRange:newRowRange:context:] + 966
17  UIKit                           0x35a7746c -[UITableView(_UITableViewPrivate) _endCellAnimationsWithContext:] + 4744
18  UIKit                           0x35a812f2 -[UITableView endUpdatesWithContext:] + 22
19  UIKit                           0x35a812ce -[UITableView endUpdates] + 10
20  sample                      0x00007574 -[TableViewController tableView:didSelectRowAtIndexPath:] (TableViewController.m:188)
21  UIKit                           0x3599c514 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 656
22  UIKit                           0x35a000e4 -[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 124
23  Foundation                      0x307ee6ce __NSFireDelayedPerform + 362
24  CoreFoundation                  0x34e69a40 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 8
25  CoreFoundation                  0x34e6bec4 __CFRunLoopDoTimer + 844
26  CoreFoundation                  0x34e6c83e __CFRunLoopRun + 1082
27  CoreFoundation                  0x34dfcebc CFRunLoopRunSpecific + 224
28  CoreFoundation                  0x34dfcdc4 CFRunLoopRunInMode + 52
29  GraphicsServices                0x30de0418 GSEventRunModal + 108
30  GraphicsServices                0x30de04c4 GSEventRun + 56
31  UIKit                           0x35976d62 -[UIApplication _run] + 398
32  UIKit                           0x35974800 UIApplicationMain + 664
33  sample                      0x000024ac main (main.m:16)
34  sample                      0x00002440 start + 32

Thread 1 name:  Dispatch queue: com.apple.libdispatch-manager
Thread 1:
0   libsystem_kernel.dylib          0x36906fbc kevent + 24
1   libdispatch.dylib               0x36aa5032 _dispatch_mgr_invoke + 706
2   libdispatch.dylib               0x36aa603a _dispatch_queue_invoke + 86
3   libdispatch.dylib               0x36aa55ea _dispatch_worker_thread2 + 186
4   libsystem_c.dylib               0x3663558a _pthread_wqthread + 258
5   libsystem_c.dylib               0x36635bbc start_wqthread + 0

Thread 2 name:  WebThread
Thread 2:
0   libsystem_kernel.dylib          0x36903c00 mach_msg_trap + 20
1   libsystem_kernel.dylib          0x36903758 mach_msg + 44
2   CoreFoundation                  0x34e6a2b8 __CFRunLoopServiceMachPort + 88
3   CoreFoundation                  0x34e6c562 __CFRunLoopRun + 350
4   CoreFoundation                  0x34dfcebc CFRunLoopRunSpecific + 224
5   CoreFoundation                  0x34dfcdc4 CFRunLoopRunInMode + 52
6   WebCore                         0x35f1a27e _ZL12RunWebThreadPv + 382
7   libsystem_c.dylib               0x3663430a _pthread_start + 242
8   libsystem_c.dylib               0x36635bb4 thread_start + 0

Thread 3:
0   libsystem_kernel.dylib          0x36903c00 mach_msg_trap + 20
1   libsystem_kernel.dylib          0x36903758 mach_msg + 44
2   CoreFoundation                  0x34e6a2b8 __CFRunLoopServiceMachPort + 88
3   CoreFoundation                  0x34e6c562 __CFRunLoopRun + 350
4   CoreFoundation                  0x34dfcebc CFRunLoopRunSpecific + 224
5   CoreFoundation                  0x34dfcdc4 CFRunLoopRunInMode + 52
6   Foundation                      0x307937f6 +[NSURLConnection(NSURLConnectionReallyInternal) _resourceLoadLoop:] + 206
7   Foundation                      0x30786382 -[NSThread main] + 38
8   Foundation                      0x307f85c6 __NSThread__main__ + 966
9   libsystem_c.dylib               0x3663430a _pthread_start + 242
10  libsystem_c.dylib               0x36635bb4 thread_start + 0

Thread 4 name:  com.apple.CFSocket.private
Thread 4:
0   libsystem_kernel.dylib          0x36905c60 __select + 20
1   CoreFoundation                  0x34e6f8f2 __CFSocketManager + 582
2   libsystem_c.dylib               0x3663430a _pthread_start + 242
3   libsystem_c.dylib               0x36635bb4 thread_start + 0

Thread 5:
0   libsystem_kernel.dylib          0x369063ec __workq_kernreturn + 8
1   libsystem_c.dylib               0x366356d8 _pthread_wqthread + 592
2   libsystem_c.dylib               0x36635bbc start_wqthread + 0

Thread 0 crashed with ARM Thread State:
    r0: 0x00000000    r1: 0x3ef7c298      r2: 0x00562ab2      r3: 0x00000000
    r4: 0x001f8c70    r5: 0x00164f80      r6: 0x2fdfd718      r7: 0x2fdfd68c
    r8: 0x2fdfd6e8    r9: 0x001fc0a0     r10: 0x001f8c70     r11: 0x00164f80
    ip: 0x3f05e428    sp: 0x2fdfd5f4      lr: 0x3609bedf      pc: 0x35fbc900
  cpsr: 0x60000030

UPDATE 1:

Ive digged deeper into this and it seems to be some bug with apple unless I've missed something obvious

I tried creating a fresh Master Detail iphone app and added a UIWebView property in the MasterViewController(UITableViewController) and initialized it

@interface MasterViewController () {
    NSMutableArray *_objects;
}

@property(nonatomic, strong) UIWebView *webView;

@end

@implementation MasterViewController

@synthesize detailViewController = _detailViewController;
@synthesize webView;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.title = NSLocalizedString(@"Master", @"Master");
        webView = [[UIWebView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 50.0)];
    }
    return self;
}

now I have set this webview as the view for footer for the section in the tableview

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    return webView;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return 50.0;
}

and in the didSelectRowAtIndexPath I have done the following

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [self.tableView beginUpdates];
    [self.tableView reloadSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationTop];
    [self.tableView endUpdates];
}

Now whenever I touch a row I get the same crash and I have no Idea why this is happening.

This is a totally fresh app with default code in it. I have only added the webView as the footer for the tableview.

4

1 回答 1

0

这很令人费解。你会尝试删除开始/结束更新:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
   [self.tableView reloadSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationTop];
}

我看到崩溃发生在endUpdates,所以到目前为止执行的所有其余部分都完美无缺。

您可能会尝试的另一件事是通过调用重新加载整个表,reloadData而不是仅通过reloadSections. 这没有优化,但是由于您的行数很少,因此实际上并不重要(如果效果更好)...

旧答案:

似乎您的表视图中的一个对象正在被释放,然后再次被访问。这是一个典型的“僵尸”问题。

您可以通过在 Xcode 中启用僵尸检测来了解正在发生的事情。

在这里您可以了解如何启用僵尸

如果您这样做了,那么您在控制台日志中收到的错误消息将提供更多关于哪个对象被过早释放的信息。

我了解到您附上了崩溃日志,因为崩溃发生在现场。在这种情况下,你有两个选择:要么在你身边重现问题(并在僵尸检测的帮助下修复它);要么 或仔细检查您的内存管理以找出表格视图中显示的对象的任何问题。

于 2012-07-24T08:03:52.443 回答