Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 无效更新:节0中的行数无效_Ios_Objective C_Iphone_Editing_Nsexception - Fatal编程技术网

Ios 无效更新:节0中的行数无效

Ios 无效更新:节0中的行数无效,ios,objective-c,iphone,editing,nsexception,Ios,Objective C,Iphone,Editing,Nsexception,我在尝试删除或添加列表中的对象时遇到问题 错误: 2014-09-04 10:59:03.815 DeleteListTest[2781:60b] *** Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit_Sim/UIKit-2935.137/UITableView.m:1368 2014-09-04 10:59:03.856 DeleteListTest[2781:60b

我在尝试删除或添加列表中的对象时遇到问题

错误:

2014-09-04 10:59:03.815 DeleteListTest[2781:60b] *** Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit_Sim/UIKit-2935.137/UITableView.m:1368 2014-09-04 10:59:03.856 DeleteListTest[2781:60b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (9) must be equal to the number of rows contained in that section before the update (10), plus or minus the number of rows inserted or deleted from that section (0 inserted, 0 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).' *** First throw call stack: ( 0 CoreFoundation 0x01b581e4 __exceptionPreprocess + 180 1 libobjc.A.dylib 0x018d78e5 objc_exception_throw + 44 2 CoreFoundation 0x01b58048 +[NSException raise:format:arguments:] + 136 3 Foundation 0x014b74de -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 116 4 UIKit 0x0066ff63 -[UITableView _endCellAnimationsWithContext:] + 13402 5 UIKit 0x0067fcea -[UITableView endUpdatesWithContext:] + 51 6 UIKit 0x0067fd18 -[UITableView endUpdates] + 41 7 DeleteListTest 0x00002ece -[MasterViewController leaveEditMode] + 270 8 DeleteListTest 0x0000301a -[MasterViewController tableView:commitEditingStyle:forRowAtIndexPath:] + 202 9 UIKit 0x006916a3 -[UITableView animateDeletionOfRowWithCell:] + 107 10 UIKit 0x0081a595 -[UITableViewCell _swipeDeleteButtonPushed] + 70 11 libobjc.A.dylib 0x018e9880 -[NSObject performSelector:withObject:withObject:] + 77 12 UIKit 0x005993b9 -[UIApplication sendAction:to:from:forEvent:] + 108 13 UIKit 0x00599345 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61 14 UIKit 0x0069abd1 -[UIControl sendAction:to:forEvent:] + 66 15 UIKit 0x0069afc6 -[UIControl _sendActionsForEvents:withEvent:] + 577 16 UIKit 0x0069a243 -[UIControl touchesEnded:withEvent:] + 641 17 UIKit 0x0092f2e3 _UIGestureRecognizerUpdate + 7166 18 UIKit 0x005d8a5a -[UIWindow _sendGesturesForEvent:] + 1291 19 UIKit 0x005d9971 -[UIWindow sendEvent:] + 1021 20 UIKit 0x005ab5f2 -[UIApplication sendEvent:] + 242 21 UIKit 0x00595353 _UIApplicationHandleEventQueue + 11455 22 CoreFoundation 0x01ae177f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15 23 CoreFoundation 0x01ae110b __CFRunLoopDoSources0 + 235 24 CoreFoundation 0x01afe1ae __CFRunLoopRun + 910 25 CoreFoundation 0x01afd9d3 CFRunLoopRunSpecific + 467 26 CoreFoundation 0x01afd7eb CFRunLoopRunInMode + 123 27 GraphicsServices 0x03a0a5ee GSEventRunModal + 192 28 GraphicsServices 0x03a0a42b GSEventRun + 104 29 UIKit 0x00597f9b UIApplicationMain + 1225 30 DeleteListTest 0x00004a4d main + 141 31 libdyld.dylib 0x0219f701 start + 1 32 ??? 0x00000001 0x0 + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb) 这是delete方法 ifeditingStyle==UITableViewCellEditingStyleDelete{ [tableTitles removeObjectAtIndex:[indexPath行]]; [自我编辑模式]; [[self tableView]重新加载数据];
有人能帮我吗?thx u:

我想你错过了打给以下人的电话:

[self.tableView deleteRowsAtIndexPaths:indexPath
                      withRowAnimation:UITableViewRowAnimationFade];
您不需要重新加载数据调用:


这看起来也会更好,因为它会向用户提供视觉反馈;与重新加载数据不同。

您是如何实现表视图数据源协议的。调试人员说,我是不兼容的指针类型,将nsindepath发送到NSarray类型的参数。此处->[self.tableView deleteRowsAtIndexPaths:indepath with RowAnimation:UITableViewRowAnimationFade];@LucaBriganti OK,修复。
if (editingStyle == UITableViewCellEditingStyleDelete) {
    [tableTitles removeObjectAtIndex:[indexPath row]];
    [self.tableView deleteRowsAtIndexPaths:@[indexPath]
                          withRowAnimation:UITableViewRowAnimationFade];
    [self leaveEditMode];