gpt4 book ai didi

ios - deleteRowsAtIndexPaths :withRowAnimation: not working

转载 作者:行者123 更新时间:2023-11-28 22:11:22 38 4
gpt4 key购买 nike

我正在尝试很好地删除 mu UITableView 的单元格:

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {

[self deleteModelForIndexPath:indexPath];

[mainTableView beginUpdates];
[mainTableView deleteRowsAtIndexPaths:indexPath withRowAnimation:UITableViewRowAnimationTop];
[mainTableView endUpdates];

}
}

这会引发以下异常:

 *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of sections.  The number of sections contained in the table view after the update (2) must be equal to the number of sections contained in the table view before the update (3), plus or minus the number of sections inserted or deleted (0 inserted, 0 deleted).'

我没有得到 (0 inserted, 0 deleted) 部分。为什么它不起作用?

谢谢

最佳答案

您应该同时更新表格数据。如果您为每一行使用数组对象,请从数组中删除已删除的对象。

关于ios - deleteRowsAtIndexPaths :withRowAnimation: not working,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22844005/

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