博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
数据刷新
阅读量:7167 次
发布时间:2019-06-29

本文共 1051 字,大约阅读时间需要 3 分钟。

 

数据刷新

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

全局刷新方法(最常用)

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

局部刷新方法(性能高)

  • 添加数据
NSArray *indexPaths = @[                        [NSIndexPath indexPathForRow:0 inSection:0], // 0组0行                        [NSIndexPath indexPathForRow:1 inSection:0]  // 0组1行                        ];[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];

转载于:https://www.cnblogs.com/LongLJ/p/5001993.html

你可能感兴趣的文章