UITableView reload 单个 cell 的 数据

2013-05-18

uitableview 中经常会对单个 cell 反复操作.

每次都 reloadData 即影响 tableview 性能又耗电.

// bad method
        [self.tableView reloadData];



// good method
        NSUInteger index = [_dataArray indexOfObject:obj];
        NSIndexPath * indexPath =  [NSIndexPath indexPathForRow:index inSection:0];
        NSArray *indexPaths = [[NSArray alloc] initWithObjects:indexPath, nil];
        [self.tableview reloadRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationNone];