tableView 的数据刷新

2016-09-07  本文已影响91人  magic_pill
数据刷新
[self.tableView reloadData];
[self.tableView insertRowsAtIndexPaths:@[
        [NSIndexPath indexPathForRow:0 inSection:0],
        [NSIndexPath indexPathForRow:1 inSection:0]]
        withRowAnimation:UITableViewRowAnimationFade];
[self.tableView reloadRowsAtIndexPaths:@[
        [NSIndexPath indexPathForRow:2 inSection:0]] 
         withRowAnimation:UITableViewRowAnimationNone];
    [self.tableView deleteRowsAtIndexPaths:@[
        [NSIndexPath indexPathForRow:0 inSection:0],
        [NSIndexPath indexPathForRow:1 inSection:0]]
        withRowAnimation:UITableViewRowAnimationMiddle];

区别:reloadData 方法通用;其它三个方法使用有注意点:数据增删改的数目必须和方法中的要修改的数据数量一样多。

数据刷新的原则
上一篇 下一篇

猜你喜欢

热点阅读