首先使用集合视图,我遇到了以下错误:
由于未捕获的异常"NSInternalInconsistencyException"而终止应用程序,原因是:"无法将种类为:UICollectionElementKindCell的视图与标识符单元格一起出列-必须为标识符注册nib或类,或连接情节提要中的原型单元格"
代码非常简单,如下所示.我一辈子都搞不清楚我错过了什么.
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath];
cell.backgroundColor = [UIColor whiteColor];
return cell;
}
集合视图控制器是使用nib和委托&;数据源都设置为文件的所有者.
视图控制器的头文件也是非常基本的.
@interface NewMobialViewController_3 : UICollectionViewController <UICollectionViewDataSource, UICollectionViewDelegateFlowLayout>
@end