说明:本文总结于WWCD 2018 :A Tour of UICollectionView相关内容(后半部分内容),由于笔者英语不好,一些地方理解和表达不到位,欢迎指正!
- Table View / Collection View Updates Coalescing(更新API高级原则 )
Action | Notes | Index Path Semantics |
---|---|---|
Delete | Descending IndexPath order | Before updates |
Insert | Ascending IndexPath order | After updates |
Move | From: Before updates ;To: After updates | |
Reload | Decompose: Delete and inserts | Before updates |
总结:按IndexPath降序删除,按IndexPath 升序插入;
Move可以分解成先删除后插入两个状态,Reload也可以分解为删除和插入
- 导致Update异常的情况(批量操作)
- 移动和删除相同的位置(Move and Delete the same location)
- 移动和插入到相同的位置(Move and Insert to the same location)
- 将超过1个位置移动到相同的位置(Move more than 1 location to the same location)
- 引用无效的IndexPath(Referencing an invalid IndexPath )
- 应用
数据源
的四个更新的原则(ApplyingData Source
Updates )
- 先将移动分解成先删除再插入的更新(Decompose Move into Delete and Insert updates)
- 再分组合并所有删除和插入更新(Combine all Delete and Insert updates)
- 先更新删除进程,按降序排列(Process Delete updates first, in descending order)
- 最后更新插入进程,按升序排列(Process Insert updates last, in ascending order )
demo.pngDemo (如图)
网友评论