我有一个非常简单的收集视图,但不知何故它不断崩溃。以下是错误消息:错误与UICollectionView
终止应用程序由于未捕获的异常“NSInternalInconsistencyException”,理由是:“不能出列类型的视图:UICollectionElementKindCell与标识符再利用 - 必须注册标识的笔尖或一类或连接在故事板”
和我的代码的原型细胞:
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *reuseCellIdentifier = @"Reuse";
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuseCellIdentifier forIndexPath:indexPath];
if (!cell) {
cell = [[UICollectionViewCell alloc]initWithFrame:CGRectMake(0, 0, 106, 95)];
}
UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 45, 45)];
imageView.image = [UIImage imageNamed:@"image_name"];
[cell addSubview:imageView];
UILabel *name = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 106, 15)];
name.text = @"user";
return cell;
}
帮助!
给小区标识为“再利用”内收集可重复使用的视图部分。 – cjd