草庐IT

UICollectionElementKindSectionHea

全部标签

iOS 7 - UICollectionElementKindSectionHeader 应用程序崩溃 ('UICollectionView dataSource is not set')

尝试向我的uicollectionview添加节标题。当我不使用节标题时,CollectionView加载正常,完全没有问题。当我尝试使用一个时,我得到了这个错误:***Terminatingappduetouncaughtexception'NSInternalInconsistencyException',reason:'UICollectionViewdataSourceisnotset'我看到其他人遇到此问题,但尚未找到解决方法。我在Storyboard中创建了uicollectionview、单元格和剖面View。我正在注册头类并在代码中设置数据源和委托(delegate)。

ios - Collection View :viewForSupplementaryElementOfKind:atIndexPath: called only with UICollectionElementKindSectionHeader

我有一个CollectionView,我希望每个部分都有页眉和页脚。我正在使用默认流布局。我有自己的UICollectionReusableView子类,我在ViewController的viewDidLoad方法中为页眉和页脚注册了每个子类。我已经实现了方法collectionView:viewForSupplementaryElementOfKind:atIndexPath:但是,对于每个部分,它仅在kind为UICollectionElementKindSectionHeader时被调用.因此我的页脚甚至都没有创建。知道为什么会这样吗? 最佳答案