美文网首页iOS开发_性能优化iOS开发错误集锦
删除cell时遇到的错误Assertion failure in

删除cell时遇到的错误Assertion failure in

作者: slowdony | 来源:发表于2017-03-16 01:48 被阅读19次

报错信息如下

原因是没有先remove数据就调用deleteRowsAtIndexPaths方法

[self deleteRowsAtIndexPaths:@[delectIndexPath] withRowAnimation:UITableViewRowAnimationFade];
[self.dataArray removeObjectAtIndex:indexPath.row];

所以报错.
修改后代码为

 NSIndexPath *delectIndexPath =[NSIndexPath indexPathForRow:indexPath.row inSection:0];
[self deleteRowsAtIndexPaths:@[delectIndexPath] withRowAnimation:UITableViewRowAnimationFade];
[self.dataArray removeObjectAtIndex:indexPath.row];

相关文章

网友评论

    本文标题:删除cell时遇到的错误Assertion failure in

    本文链接:https://www.haomeiwen.com/subject/nxhdnttx.html