をセットアップしようとしていますUICollectionView
。最初はbasicを使ってUICollectionViewCell
いましたが、うまく動いていて、セルが表示されていました。
UICollectionViewCell
次に、セルに画像を表示できるように、独自の collectionViewCell (サブクラス化) を作成しました。ストーリーボードのカスタム セルを識別子にリンクし、適切なクラスも指定しました。
ただし、このエラーが引き続き発生し、理由がわかりません。
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'could not dequeue a view of kind: UICollectionElementKindCell with identifier MediaCell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'
にこの行を追加することでバグに対処することができましたviewDidLoad
が、チュートリアルでは、私がフォローしていた人はそれを使用していませんでした:
[self.collectionView registerClass:[MediaCollectionViewCell class] forCellWithReuseIdentifier:@"MediaCell"];
問題は、追加すると、collectionView が黒のままで、データが表示されないことです。