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

// OC 刷新tableView的行和組

// 刷新某些行,傳入一個indexPath的數(shù)組(可以刷新多行)

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

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



// 刷新某一組

NSIndexSet *indexSet = [[NSIndexSet alloc]initWithIndex:1]; // 組數(shù)

[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的行和組

    // 刷新某些行 (傳入?yún)?shù)是 元素為IndexPath類型的數(shù)組“[IndexPath]”),所以可以刷新某幾行

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

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

    // 刷新第幾組,直接傳入要刷新的組數(shù)集合 “[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

?著作權歸作者所有,轉載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內(nèi)容