iOS 关于reloadRowsAtIndexPaths:withRowAnimation:

情况

在一个列表中
模拟数据状态改变后
使用reloadRowsAtIndexPaths:withRowAnimation:来刷新cell
结果状态改变
始终不尽人意!


无尽地测试

方法reloadRowsAtIndexPaths:withRowAnimation:的部分官方解释:

Reloading a row causes the table view to ask its data source for a new cell for that row. The table animates that new cell in as it animates the old row out. Call this method if you want to alert the user that the value of a cell is changing. If, however, notifying the user is not important—that is, you just want to change the value that a cell is displaying—you can get the cell for a particular row and set its new value.

度娘翻译:
重新加载行会导致表视图向其数据源请求该行的新单元格。该表将新单元格动画化,同时将旧行动画化。如果要通知用户单元格的值正在更改,请调用此方法。但是,如果通知用户并不重要,也就是说,您只想更改单元格显示的值,就可以获取特定行的单元格并设置其新值。


原因

方法reloadRowsAtIndexPaths:withRowAnimation: 会导致的问题是
cell 的数量不够时
会创建新的cell
所以
你以为你刷新的
是原来的那一行
结果
系统给你返回了一个新的!
视图的状态都是新的

所以
正确姿势是
先获取指定的cell
再通过调用cell的方法刷新界面。


一款轻量级的布局框架,自动布局

https://github.com/xjh093/JHFrameLayout


  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

豪冷啊

你的鼓励是对我的认可!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值