_嵌入式开发_

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

iOS tableview中的 

- (void)reloadRowsAtIndexPaths:(NSArray<NSIndexPath *> *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation 会创建一个新的cell

- (void)deleteRowsAtIndexPaths:(NSArray<NSIndexPath *> *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation; 删除一个cell后,其他的cell不会变化,仅会渲染一个新可视的cell

 

不要吧indexpath这个作为cell的一个属性,因为在删除、插入的情况下,只是删除、插入的cell的indexpath会变化,其他的cell如果没有重新赋值都是不变的,这样会有很多不确定的问题。

如果需要获取cell的indexpath,一定要NSIndexPath *reallIndexPath = [self.tableView indexPathForCell:cell];

不要指望table会自动更新或自动reload。

 

posted on 2020-02-25 17:28  _嵌入式开发_  阅读(147)  评论(0编辑  收藏  举报