这是我想出的:
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:1]; // my table view has 2 sections
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationTop];
每次我构建和运行时,它都会抛出以下异常:
Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update must be equal to the number of rows contained in that section before the update, plus or minus the number of rows added or removed from that section.
这有点令人困惑。该部分设置为 1,但异常显示它为 0。
最佳答案
我想通了。
除了前面提到的代码,我还需要对数据源进行更改
[items removeObjectAtIndex:0];
关于iphone - 如何手动删除 UITableView 中的一行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/915095/