美文网首页
UITableViewCell 的 数据刷新

UITableViewCell 的 数据刷新

作者: YANGGQ | 来源:发表于2016-10-28 00:25 被阅读22次

  • 添加数据
  • 删除数据
  • 更新数据

全局刷新方法(最常用)

[self.tableView reloadData];
// 屏幕上的所有可视的cell都会刷新一遍

局部刷新方法

  • 添加数据
NSArray *indexPaths = @[
                        [NSIndexPath indexPathForRow:0 inSection:0],
                        [NSIndexPath indexPathForRow:1 inSection:0]
                        ];
[self.tableView insertRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationRight];
  • 删除数据
NSArray *indexPaths = @[
                        [NSIndexPath indexPathForRow:0 inSection:0],
                        [NSIndexPath indexPathForRow:1 inSection:0]
                        ];
[self.tableView deleteRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationMiddle];
  • 更新数据(仅仅是修改已经存在的数据)
NSArray *indexPaths = @[
                        [NSIndexPath indexPathForRow:0 inSection:0],
                        [NSIndexPath indexPathForRow:1 inSection:0]
                        ];
[self.tableView relaodRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationMiddle];

相关文章

网友评论

      本文标题:UITableViewCell 的 数据刷新

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