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

         }

        */





猜你喜欢

转载自blog.csdn.net/iamonmyownway/article/details/73480346
今日推荐