'Invalid update: invalid number of sections. The number of sections contained in the collection view after the update (7) must be equal to the number of sections contained in the collection view before the update (9), plus or minus the number of sections inserted or deleted (1 inserted, 1 deleted).'复制代码
`self.collectionView.reloadSections(IndexSet(integer:sender.tag))`
``` collectionView.performBatchUpdates({ UIView.performWithoutAnimation { self.collectionView.reloadSections(IndexSet(integer:sender.tag)) } }) { (success) in } ```
使用这个方法, 能够 collectionView 暂时锁定 collectionView 的数据,相似 tableview 的 beginData, 或者 enddata 方法缓存
self.collectionView.reloadData() self.collectionView.collectionViewLayout.invalidateLayout()
核心方法是这个 invalidateLayout()bash
将collectionViewLayout 的缓存信息销毁, 从新生成 layout异步