ios 刷新头像_iOS UITableView 刷新

UITableView常用的刷新方式

// UITableView.h

// 方式1:刷新整个table

- (void)reloadData;

// 方式2:刷新指定的cells

- (void)reloadRowsAtIndexPaths:(NSArray *)indexPaths

withRowAnimation:(UITableViewRowAnimation)animation;

// 方式3:多个insert/delete批量事务处理

- (void)beginUpdates; // allow multiple insert/delete of rows and sections to be animated simultaneously. Nestable

- (void)endUpdates; // only call insert/delete/reload calls or change the editing state inside an update block. otherwise things like row count, etc. may be invalid.

方式1会刷新整个table,一般情况下不建议使用

当cell显示的数据需要发生变化时,通常采用方式2:只刷新指定的cell(s),对table中的其它cell不会产生影响。

当insert/delete cell的时候,一般使用方式3,

单个Cell的局部刷新

案例

我们现在有一个cell,需要显示如下3类信息:

用户基本信息:昵称、性别、头像、

用户的粉丝数量

用户的关注数量

以上3类信息的数据由服务端提供了3个不同的接口调用。

要将这个cell的数据显示完全,需要进行3次接口调用,如果按照方式2则需要将cell刷新3次!!!如下我将介绍一种cell局部刷新的方式:

cell局部刷新

// 更新用户基本信息

[cell updateBasicView];

[tableView beginUpdate];

[tableView endUpdate];

// 更新�用户粉丝数量

[cell updateFansView];

[tableView beginUpdate];

[tableView endUpdate];

// 更新�用户关注数量

[cell updateFollowView];

[tableView beginUpdate];

[tableView endUpdate];

这样cell就做到了局部刷新,是不是很简单?!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值