繁体   English   中英

删除带有动画的单元格时发生错误

[英]Error Occurs When Deleting Cell with Animation

[[PeopleManager shared] removePersonAtIndex:indexPath.row withGroupIndex:currentGroupIndex];

[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation: UITableViewRowAnimationNone];

PeopleManager类具有一个人员数组(NSMutableArray)。

我的错误不是索引值错误。

它正常工作99.9%,没有错误。 但有时会发生错误

错误代码

2012-02-03 17:17:53.232电话簿[343:707] *-[UITableView _endCellAnimationsWithContext:],/ SourceCache / UIKit / UIKit-1912.3 / UITableView.m的断言失败:m:1046 2012-02-03 17:17: 53.239 PhoneBook [343:707] *由于未捕获的异常“ NSInternalInconsistencyException”而终止应用程序,原因:“无效更新:部分0中的行数无效。更新(1)之后现有部分中包含的行数必须相等到更新之前该部分中包含的行数(1),加上或减去从该部分插入或删除的行数(插入0,删除1),加上或减去移入或删除该行的行数部分(移入0,移出0)。” 终止称为抛出异常杀死

如何解决??? 我读了错误代码。但我不知道如何解决...

您应该在beginUpdates和endUpdates对中包装好deleteRows ...调用:

[tableView beginUpdates];
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation: UITableViewRowAnimationNone];
[tableView endUpdates];

并确保您的numberOfRowsForSection:方法返回正确的更新值

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM