UITableView 是否“开始更新"?和 UICollectionView “performBatchUpdates"有相同的行为吗? [英] Does the UITableView "beginUpdates" and UICollectionView "performBatchUpdates" have the same behavior?

查看:26
本文介绍了UITableView 是否“开始更新"?和 UICollectionView “performBatchUpdates"有相同的行为吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我开始想知道 UITableView 中的beginUpdates"和 UICollectionView 中的performBatchUpdates"是否具有相同的行为时,我正在浏览文档.如果是这样,即使它们实际上是同一个东西,它们的称呼也不同吗?

I was browsing the documentations, when I started wondering if "beginUpdates" in a UITableView and "performBatchUpdates" in a UICollectionView have the same behavior. If so, is there a reason, that they're called differently, even though they're virtually the same thing?

谢谢!

推荐答案

UITableViewbeginUpdates 必须与对 endUpdates 的调用匹配.UICollectionViewperformBatchUpdates:completion 方法不需要您在进行更新时回调集合视图,大概是因为您传入的工作块更新集合视图包含在这些调用中.

UITableView's beginUpdates must be matched with a call to endUpdates. UICollectionView's performBatchUpdates:completion method does not require you to call back to the collection view when you are doing with the updates, presumably because the block of work that you pass in to update the collection view is wrapped with those calls for you.

UITableView 早于添加到 Objective-C 的块.我怀疑 UITableView 没有类似 API 的原因是它的公共 API 是在可以合并块之前设计的.

UITableView predates blocks being added to Objective-C. I suspect the reason there isn't a similar API for UITableView is that its public API was designed before blocks could be incorporated.

这篇关于UITableView 是否“开始更新"?和 UICollectionView “performBatchUpdates"有相同的行为吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆