美文网首页
day10-数据刷新02局部刷新

day10-数据刷新02局部刷新

作者: js_huh | 来源:发表于2020-06-07 23:50 被阅读0次

    数据刷新01全局刷新


    • reloadData - 全局刷新,屏幕能看见的cell的数据,全部再次加载.
    • 局部刷新 : 指定的某个/某几个"cell"的刷新
      • insertRowsAtIndexPaths: withRowAnimation: 增加的局部刷新
        作用: UITableView中,在索引路径标示处,插入行. 并带有插入动画
        参数: 
          indexPaths - 索引路径对象的数组,每个对象代表一个行索引和一个部分索引,它们一起标识表视图中的一行。
          animation - 插入的动画选项
        
         // 局部刷新 - 插入指定行
        NSArray *arrayTemp = @[[NSIndexPath indexPathForRow:0 inSection:0]];
        [self.tableView insertRowsAtIndexPaths:arrayTemp withRowAnimation: UITableViewRowAnimationRight];
        
      • reloadRowsAtIndexPaths: withRowAnimation: 更新的局部刷新
        作用: 使用给定的动画效果,重新加载指定行.
        参数: 
          indexPaths - 标识要重新加载的行的对象数组
          animation - 动画
        
         //单个cell进行局部刷新,(前提有存在indexpath时)
        [self.tableView reloadRowsAtIndexPaths:@[indexpath] withRowAnimation:UITableViewRowAnimationLeft];
        
      • deleteRowsAtIndexPaths: withRowAnimation: 删除的局部刷新
        //多个cell,进行局部刷新
        NSArray *indexpaths = @[
                             [NSIndexPath indexPathForRow:0 inSection:0],
                             [NSIndexPath indexPathForRow:1 inSection:0]
                             ];
        [self.tableView deleteRowsAtIndexPaths:indexpaths withRowAnimation:UITableViewRowAnimationBottom];
        

    也可以看看

    NSIndexPath - 索引路径

    相关文章

      网友评论

          本文标题:day10-数据刷新02局部刷新

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