Does the UITableView “beginUpdates” and UICollecti

2019-06-14 23:17发布

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?

Thanks!

1条回答
叼着烟拽天下
2楼-- · 2019-06-14 23:50

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 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.

查看更多
登录 后发表回答