ios swift tableView 刷新某一行某一组,及UITableViewRowAnimation

// OC 刷新tableView的行和组

// 刷新某些行,传入一个indexPath的数组(可以刷新多行)

NSIndexPath *indexPath = [NSIndexPath indexPathForRow:3 inSection:0];

[self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];



// 刷新某一组

NSIndexSet *indexSet = [[NSIndexSet alloc]initWithIndex:1]; // 组数

[self.tableView reloadSections:indexSet withRowAnimation:UITableViewRowAnimationFade];

// 刷新从第0组开始的两组,也就是刷新 第0组 和 第1组

NSIndexSet *indexSet = [[NSIndexSet alloc]initWithIndexesInRange:NSMakeRange(0, 2)];

[self.tableView reloadSections:indexSet withRowAnimation:UITableViewRowAnimationFade];

// Swift 刷新tableView的行和组

    // 刷新某些行 (传入参数是 元素为IndexPath类型的数组“[IndexPath]”),所以可以刷新某几行

    let indexPath: IndexPath = IndexPath.init(row: 1, section: 0)

    self.tableView.reloadRows(at: [indexPath], with: .fade)

    // 刷新第几组,直接传入要刷新的组数集合 “[section]”

    self.tableView.reloadSections([1], with: .fade)

/************* UITableViewRowAnimation 的风格效果 ****************/

/*

     public enum UITableViewRowAnimation : Int {

     

     case fade  // 淡入淡出

     

     case right // slide in from right (or out to right) 从右滑入(或从右出去)

     

     case left  // 从左滑入

     

     case top   // 从上滑入

     

     case bottom    // 从下滑入

     

     case none // available in iOS 3.0

     

     case middle // available in iOS 3.2.  attempts to keep cell centered in the space it will/did occupy

     

     case automatic // available in iOS 5.0.  chooses an appropriate animation style for you

     }

    */

原文链接:https://blog.csdn.net/IAmOnMyOwnWay/article/details/73480346

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容