【发布时间】:2016-05-26 06:50:49
【问题描述】:
是的,这个标题有很多问题。但是没有一个能解决我的问题。 在我的应用程序中,我使用表格视图中的部分在单击它们时显示下拉列表。并且有 UIButton 来添加数据,它将用户带到另一个视图来添加。 用户添加数据并按完成后,我正在使用关闭视图控制器返回。 因此,现在没有任何部分将使用新数据 +1。 当用户现在按下该部分时,应用程序将退出并出现此错误
'NSInternalInconsistencyException',原因:'无效更新:无效的节数。更新后表视图中包含的节数(35)必须等于更新前表视图中包含的节数(34),加上或减去插入或删除的节数(0插入,0已删除)。'
我的代码是
NSMutableArray *tempArr=[[NSMutableArray alloc]init];
for(int i=0;i<username_rank.count;i++)
{
NSIndexPath *indexx=[NSIndexPath indexPathForRow:i inSection:btn.tag];
[tempArr addObject:indexx];
}
[tournament_table insertRowsAtIndexPaths:tempArr withRowAnimation:UITableViewRowAnimationTop];
*** First throw call stack:
(
0 CoreFoundation 0x000000010e7b7d85 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010e22bdeb objc_exception_throw + 48
2 CoreFoundation 0x000000010e7b7bea +[NSException raise:format:arguments:] + 106
3 Foundation 0x000000010de75d5a -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 198
4 UIKit 0x000000010fbca0dc -[UITableView _endCellAnimationsWithContext:] + 14140
5 UIKit 0x000000010fbe0cf0 -[UITableView _updateRowsAtIndexPaths:updateAction:withRowAnimation:] + 303
6 Sports Lion 0x000000010d720c3f -[entertheden Btntap_expand:] + 447
7 UIKit 0x000000010fa9ca8d -[UIApplication sendAction:to:from:forEvent:] + 92
8 UIKit 0x000000010fc0fe67 -[UIControl sendAction:to:forEvent:] + 67
9 UIKit 0x000000010fc10143 -[UIControl _sendActionsForEvents:withEvent:] + 327
10 UIKit 0x000000010fc0f263 -[UIControl touchesEnded:withEvent:] + 601
11 UIKit 0x000000010ff84c52 _UIGestureRecognizerUpdate + 10279
12 UIKit 0x000000010fb0f48e -[UIWindow _sendGesturesForEvent:] + 1137
13 UIKit 0x000000010fb106c4 -[UIWindow sendEvent:] + 849
14 UIKit 0x000000010fabbdc6 -[UIApplication sendEvent:] + 263
15 UIKit 0x000000010fa95553 _UIApplicationHandleEventQueue + 6660
16 CoreFoundation 0x000000010e6dd301 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
17 CoreFoundation 0x000000010e6d322c __CFRunLoopDoSources0 + 556
18 CoreFoundation 0x000000010e6d26e3 __CFRunLoopRun + 867
19 CoreFoundation 0x000000010e6d20f8 CFRunLoopRunSpecific + 488
20 GraphicsServices 0x0000000113250ad2 GSEventRunModal + 161
21 UIKit 0x000000010fa9af09 UIApplicationMain + 171
22 Sports Lion 0x000000010d77050f main + 111
23 libdyld.dylib 0x0000000111d4c92d start + 1
24 ??? 0x0000000000000001 0x0 + 1
) libc++abi.dylib:以 NSException 类型的未捕获异常终止
谢谢
【问题讨论】:
-
显示完整的堆栈跟踪。
-
好的,所以异常文本解释了实际问题是什么,是吗?调用
updateRowsBlahBlah后,您已更改 0 行。如果您要在另一个视图控制器中将数据添加到模型中,而该视图控制器此后已被解除,那么如果您问我,那不是要使用的写调用。您的问题也涉及部分,但调用/错误/等似乎与行有关。 -
在展示另一个视图控制器之前,节数为 34 并且从视图控制器返回后,tableview 将使用来自服务器的新数据进行更新,这些数据来自他在新视图控制器中添加的服务器。所以现在将有 35 个部分包含新数据。
-
@nandy :临时修复可以更改 insertRowsAtIndexPaths 并将其替换为 [tableView reloadData]
-
当用户点击任何部分时,就会出现此错误。
标签: ios objective-c sections