iOS Assertion Failure in UICollectionView

后端 未结 7 1379
抹茶落季
抹茶落季 2020-12-17 08:07

I\'m getting the error ...

*** Assertion failure in -[UICollectionView _dequeueReusableViewOfKind:withIdentifier:forIndexPath:], /SourceCache/UIKit/UIKit-237         


        
7条回答
  •  一向
    一向 (楼主)
    2020-12-17 08:57

    Make sure that if you use the registerNib: method:

    UINib *nibH = [UINib nibWithNibName:HEADER_ID bundle:nil];
    [collectionView registerNib:nibH
     forSupplementaryViewOfKind:UICollectionElementKindSectionHeader 
            withReuseIdentifier:HEADER_ID];
    

    that ALSO in the nib file, when you select the top-level collection reusable view, use the attributes inspector, and make sure the Identifier is set to the same value you are passing in to the withReuseIdentifier: parameter.

提交回复
热议问题