gpt4 book ai didi

ios - 空的 UITableView

转载 作者:行者123 更新时间:2023-11-28 20:18:56 25 4
gpt4 key购买 nike

我有一个可编辑的 tableView,但我无法删除最后一个对象,这是我的方法:

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView beginUpdates];
if (editingStyle == UITableViewCellEditingStyleDelete)
{
[self deletePermittedFriend:[friendsIDs objectAtIndex:indexPath.row]];
[tableDataList removeObjectAtIndex:indexPath.row];
}

[tableView endUpdates];
}

如果 tableDataList MutableArray 只有最后一个对象,则会给我一个错误:

* Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit/UIKit-2380.17/UITableView.m:1070 2013-05-21 11:41:47.306 EzMall[3398:907] * 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 (0) must be equal to the number of rows contained in that section before the update (1), 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).'

最佳答案

看来您忘记调用这个 UITableView 方法了:

– deleteRowsAtIndexPaths:withRowAnimation:

顺便说一句:阅读错误消息始终是一个好习惯。

关于ios - 空的 UITableView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16672849/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com