美文网首页
iOS TableView刷新cell section

iOS TableView刷新cell section

作者: Lxin_ | 来源:发表于2016-12-29 16:08 被阅读226次
    • 刷新cell
        NSIndexPath *indexPath=[NSIndexPath indexPathForRow:3 inSection:0];    
        [self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath,nil] withRowAnimation:UITableViewRowAnimationFade];
    
    • 刷新section
        NSIndexSet *indexSet=[[NSIndexSet alloc]initWithIndex:2];    
        [self.tableview reloadSections:indexSet withRowAnimation:UITableViewRowAnimationFade];
    

    查阅了一些资料,对比reloadSections、reloadRows与reloadData的区别。

    1. 前两者可以加动画,后者不可以。
    2. 主要是性能的区别:三者的性能在100000次以内,相差无几。
    3. 数据源动态变化的情况下,例如在某些页面中,每个Section中的row是动态变化的,单独使用reloadSection会导致某些bug。而使用reloadData不会出现这个bug。
    4. 更多情况下,是搭配beginUpdates和endUpdates来实现 deleteSections:withRowAnimation:的功能。

    相关文章

      网友评论

          本文标题:iOS TableView刷新cell section

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