1. 程式人生 > >iOS UITableView區域性重新整理 重新整理單個cell或section

iOS UITableView區域性重新整理 重新整理單個cell或section

/**
     *  單個cell的重新整理
     */
    //1.當前所要重新整理的cell,傳入要重新整理的 行數 和 組數
    NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
    //2.將indexPath新增到陣列
    NSArray <NSIndexPath *> *indexPathArray = @[indexPath];
    //3.傳入陣列,對當前cell進行重新整理
    [tableView reloadRowsAtIndexPaths:indexPathArray withRowAnimation:UITableViewRowAnimationAutomatic];
    
    /**
     *  單個Section的重新整理
     */
    //1.傳入要重新整理的組數
    NSIndexSet *indexSet=[[NSIndexSet alloc] initWithIndex:0];
    //2.傳入NSIndexSet進行重新整理
    [tableView reloadSections:indexSet withRowAnimation:UITableViewRowAnimationAutomatic];