我有一个带有简单 UICollectionViewFlowLayout
的 UICollectionView
。在 iOS 15 上,首次加载 View 和设置项目时发生异常。
设置项目时在主线程上调用:
var snapshot = NSDiffableDataSourceSnapshot<Section, PageItem>()
snapshot.appendSections([.main])
snapshot.appendItems(filteredPages)
dataSource.apply(snapshot, animatingDifferences: true)
我收到以下异常:
'the invalidation context ((null)) sent to -[UICollectionViewFlowLayout invalidateLayoutWithContext:] is not an instance of type UICollectionViewFlowLayoutInvalidationContext or a subclass'
terminating with uncaught exception of type NSException
在 iOS 14 上运行相同的项目不会崩溃。
最佳答案
问题是动画变化,所以从:
dataSource.apply(snapshot, animatingDifferences: true)
到
dataSource.apply(snapshot, animatingDifferences: false)
关于ios - 在 iOS 15 上应用快照时崩溃 UICollectionViewFlowLayout,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70064358/