Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/reporting-services/3.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
Ios7 Xcode错误-iOS 7向左滑动以显示删除功能_Ios7_Xcode5 - Fatal编程技术网

Ios7 Xcode错误-iOS 7向左滑动以显示删除功能

Ios7 Xcode错误-iOS 7向左滑动以显示删除功能,ios7,xcode5,Ios7,Xcode5,好的,首先我是一个绝对的初学者,我的问题实际上涉及我的第一个项目。我会慢慢来,确保我明白一切。提前谢谢你的耐心 我在网上学习了一个关于创建待办事项列表应用程序的Xcode教程。正如教程所解释的,我成功地创建了这个。但是,我现在想继续并自定义应用程序。我特别想添加一个“向左滑动以显示删除按钮”功能,因为另一个没有。我在网上找到了这个的代码片段。我把它贴在下面 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NS

好的,首先我是一个绝对的初学者,我的问题实际上涉及我的第一个项目。我会慢慢来,确保我明白一切。提前谢谢你的耐心

我在网上学习了一个关于创建待办事项列表应用程序的Xcode教程。正如教程所解释的,我成功地创建了这个。但是,我现在想继续并自定义应用程序。我特别想添加一个“向左滑动以显示删除按钮”功能,因为另一个没有。我在网上找到了这个的代码片段。我把它贴在下面

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
    XYZTopList *tappedItem = [self.XYZTopList objectAtIndex:indexPath.row];
    tappedItem.completed = !tappedItem.completed;
    [tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
}
然而,每当我在模拟器中运行我的程序时,程序运行得非常漂亮,甚至向左滑动,显示红色的删除框。但是,当我单击“删除”时,我会收到此错误消息。我尽我所能在网上搜索,发现了一些关于按钮和插座可能导致连接错误的信息。但是,在此错误消息中,它描述了更新(删除)前后不相等的行数


基本上,我对这些错误消息和调试没有任何线索。感谢您事先提供的任何帮助,以及使用初学者(渴望进步)能够理解的术语。

该问题将更详细地描述,其中说明:

'无效更新:节0中的行数无效。更新(4)后现有节中包含的行数必须等于更新(4)前该节中包含的行数,加上或减去从该节中插入或删除的行数(0插入,1删除),加上或减去移入或移出该节的行数(0移入,0移出).'

具体来说,您已经告诉表某个单元格已被删除,但当它获取表内容时,它的编号与以前相同

删除时,请确保正在从
self.XYZTopList
中删除对象。使用提供的代码,有点难看出您将在何处或如何做到这一点,但以下是一些相关问题,将更详细地介绍:


我理解你的意思,非常感谢你的简单解释。我还可以与您共享哪些代码来帮助您更好地理解这个问题?您是否在控制器中实现了tableView:CommittedItingStyle:ForRowatineXpath:?请参阅我没有看到的苹果文档示例。当我试图实现我找到的代码片段时,我遇到了一个丢失的“reloadData”。恐怕我的待办事项应用程序太基本了,添加此功能所需的资源远远超出我的预期/
[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit_Sim/UIKit-2903.23/UITableView.m:1330
2014-01-07 14:04:31.307 Top That[3281:70b] *** 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 (4) must be equal to the number of rows contained in that section before the update (4), plus or minus the number of rows inserted or deleted from that section (0 inserted, 1 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                      0x0173c5e4 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x014bf8b6 objc_exception_throw + 44
    2   CoreFoundation                      0x0173c448 +[NSException raise:format:arguments:] + 136
    3   Foundation                          0x0109ffee -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 116
    4   UIKit                               0x002fe85d -[UITableView _endCellAnimationsWithContext:] + 13402
    5   UIKit                               0x0030e550 -[UITableView _updateRowsAtIndexPaths:updateAction:withRowAnimation:] + 337
    6   UIKit                               0x0030e5cb -[UITableView deleteRowsAtIndexPaths:withRowAnimation:] + 55
    7   Top That                            0x00002821 -[XYZTopListViewController tableView:commitEditingStyle:forRowAtIndexPath:] + 193
    8   UIKit                               0x0031dba3 -[UITableView animateDeletionOfRowWithCell:] + 107
    9   UIKit                               0x0049d695 -[UITableViewCell _swipeDeleteButtonPushed] + 70
    10  libobjc.A.dylib                     0x014d1874 -[NSObject performSelector:withObject:withObject:] + 77
    11  UIKit                               0x0022f0c2 -[UIApplication sendAction:to:from:forEvent:] + 108
    12  UIKit                               0x0022f04e -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
    13  UIKit                               0x003270c1 -[UIControl sendAction:to:forEvent:] + 66
    14  UIKit                               0x00327484 -[UIControl _sendActionsForEvents:withEvent:] + 577
    15  UIKit                               0x00326733 -[UIControl touchesEnded:withEvent:] + 641
    16  UIKit                               0x005a1c7f _UIGestureRecognizerUpdate + 7166
    17  UIKit                               0x0026c19a -[UIWindow _sendGesturesForEvent:] + 1291
    18  UIKit                               0x0026d0ba -[UIWindow sendEvent:] + 1030
    19  UIKit                               0x00240e86 -[UIApplication sendEvent:] + 242
    20  UIKit                               0x0022b18f _UIApplicationHandleEventQueue + 11421
    21  CoreFoundation                      0x016c583f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
    22  CoreFoundation                      0x016c51cb __CFRunLoopDoSources0 + 235
    23  CoreFoundation                      0x016e229e __CFRunLoopRun + 910
    24  CoreFoundation                      0x016e1ac3 CFRunLoopRunSpecific + 467
    25  CoreFoundation                      0x016e18db CFRunLoopRunInMode + 123
    26  GraphicsServices                    0x036e19e2 GSEventRunModal + 192
    27  GraphicsServices                    0x036e1809 GSEventRun + 104
    28  UIKit                               0x0022dd3b UIApplicationMain + 1225
    29  Top That                            0x000035ed main + 141
    30  libdyld.dylib                       0x01d7a70d start + 1
    31  ???                                 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)