有人见过这种错误吗?
***因未捕获异常'NSInternalInconsistencyException'而终止应用,原因:'Error: no elementKind for supplementary. 请在UICollectionView上提交一个bug,因为这应该是不可能的。"[在此输入图片描述][1] 。
在为头部创建布局时,我忘了给它一个种类,导致崩溃。所以,如果有人看到这个错误,可能是因为你正在创建一个只有大小的头。
我把这个改了
let header = NSCollectionLayoutBoundarySupplementaryItem(layoutSize: headerSize)
到
let header = NSCollectionLayoutBoundarySupplementaryItem(layoutSize: headerSize, elementKind: UICollectionView.elementKindSectionHeader, alignment: .top)
而这一切都很好