rvi*_*007 6 uitableview ios ios8
我有一个UITableView与一堆部分/行.我一直受到一个奇怪的错误的打击,当我删除一行时,我的程序会崩溃.我的删除代码如下:
[self.tableView beginUpdates];
NSMutableArray* myArray = [self.myArray mutableCopy];
[myArray removeObjectAtIndex:indexPath.row];
self.myArray = myArray;
[self.tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
[self.tableView endUpdates];
Run Code Online (Sandbox Code Playgroud)
调试器在endUpdates
出现以下错误时抛出错误.
*由于未捕获的异常'NSInvalidArgumentException'终止应用程序,原因:'* - [__ NSArrayM insertObject:atIndex:]:object不能为nil'
现在,为了节省每个人一些时间,我已经进行了广泛的测试和验证,我的数据源更新和删除正确的indexPath,一切都是绝对正确的.我只是注意到只有当我一直滚动到我的tableview底部时才会出现问题,这样我就不能再滚动了,然后删除页面上可见区域中的一个单元格.
我可以在我的tableview中的任何其他位置正确删除,只要它下面有更多内容,但是一旦我在tableview的末尾,删除就会抛出此错误.
如果它有帮助,我基本上有一个UITableViewController
(普通风格)UIPageViewController
.我已经尝试删除UIPageViewController并只是推入UITableViewController,但仍然会发生此错误.
有谁知道我怎么能克服这个?
编辑:
似乎很多人仍然认为它可能是阵列,但这就是事情.我可以在我的tableview中移动我的部分(所有部分都有可以删除的行).当tableview完全滚动到底部时,我会在删除任何可见部分中的行时发生崩溃.这段代码片段被抽象并在所有部分中使用,所以我很确定代码是正确的.
当我删除tableview位于中间的部分中的一行时,我注意到该行向上滑动以删除,即使我说使用淡入淡出动画.动画为其下方的行或部分设置动画,这是正确的行为.我觉得这可能与tableview的内容结束时有关,它试图向上滚动,但没有任何东西.
HACK:
我刚刚实现的一个hack是在tableView.tableFooterView中放置一个与我的tableView相同大小的UIView.这会导致我的tableView具有更多可滚动的大小,我不喜欢这样,但是由于在删除最后一个单元格时有更多可滚动空间向上移动,所以不会发生崩溃.我很感激我无需这样做的解决方案.
好吧,如果页脚视图非常大,它似乎才有效.如果我使页脚视图更小,如100像素,如果滚动到tableview的边缘,它仍然会崩溃.
Stack Trace:
(调试器将首先崩溃到上面代码中的endUpdates行,当我在调试器上再次播放两次时,此堆栈跟踪会出现)
2014-07-18 05:52:41.314 ScriptChart[26419:905949] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
*** First throw call stack:
(
0 CoreFoundation 0x0000000109c9f055 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010d1d8a1c objc_exception_throw + 45
2 CoreFoundation 0x0000000109b6d92a -[__NSArrayM insertObject:atIndex:] + 954
3 UIKit 0x000000010b86c424 __46-[UITableView _updateWithItems:updateSupport:]_block_invoke915 + 177
4 UIKit 0x000000010b803a4c +[UIView(UIViewAnimationWithBlocks) _setupAnimationWithDuration:delay:view:options:factory:animations:start:animationStateGenerator:completion:] + 473
5 UIKit 0x000000010b803ca1 +[UIView(UIViewAnimationWithBlocks) animateWithDuration:delay:options:animations:completion:] + 57
6 UIKit 0x000000010b86bfc3 -[UITableView _updateWithItems:updateSupport:] + 2803
7 UIKit 0x000000010b8660b2 -[UITableView _endCellAnimationsWithContext:] + 11934
8 ScriptChart 0x000000010863f272 -[SCLabListNoteSection deleteCell:] + 1250
9 ScriptChart 0x00000001085e127f __45-[SCLabPanelTableViewCell infoButtonPressed:]_block_invoke127 + 207
10 UIKit 0x000000010b9e0fe7 -[UIAlertController _fireOffActionOnTargetIfValidForAction:] + 55
11 UIKit 0x000000010b9e14d5 __85-[UIAlertController _dismissAnimated:triggeringAction:triggeredByPopoverDimmingView:]_block_invoke + 30
12 UIKit 0x000000010b892bc4 -[UIPresentationController transitionDidFinish:] + 1118
13 UIKit 0x000000010b894d8e __56-[UIPresentationController runTransitionForCurrentState]_block_invoke_2 + 133
14 UIKit 0x000000010bec4123 -[_UIViewControllerTransitionContext completeTransition:] + 110
15 UIKit 0x000000010b8037fd -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 326
16 UIKit 0x000000010b7ec42a -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 209
17 UIKit 0x000000010b7ec760 -[UIViewAnimationState animationDidStop:finished:] + 76
18 QuartzCore 0x000000010b4dff9e _ZN2CA5Layer23run_animation_callbacksEPv + 308
19 libdispatch.dylib 0x000000010d537d64 _dispatch_client_callout + 8
20 libdispatch.dylib 0x000000010d523f82 _dispatch_main_queue_callback_4CF + 941
21 CoreFoundation 0x0000000109c07ae9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
22 CoreFoundation 0x0000000109bca46b __CFRunLoopRun + 2043
23 CoreFoundation 0x0000000109bc9a06 CFRunLoopRunSpecific + 470
24 GraphicsServices 0x000000010db6cabf GSEventRunModal + 161
25 UIKit 0x000000010b792cf8 UIApplicationMain + 1282
26 ScriptChart 0x00000001085ca153 main + 179
27 libdyld.dylib 0x000000010d56c145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1571 次 |
最近记录: |