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];

猜你喜欢

转载自blog.csdn.net/Alexander_Wei/article/details/78914505