Ios TableViewCell中的集合视图为XIB
所以我在tableViewCell中有一个collectionView 当tableViewCell出现在我的故事板中时,一切都很好 我决定将tableViewCell移动到它自己的XIB,因为故事板落后了。现在它给出了错误-> ****由于未捕获的异常“NSInternalInconsistencyException”,正在终止应用程序,原因:“无法将视图出列。” 种类:UICollectionElementKindCell,标识符为TagCellReview- 必须为标识符注册nib或类,或连接 故事板中的原型单元**** 在CellForRowAtIndexPathTableView中--> cellForItemAtIndexPath集合视图-->Ios TableViewCell中的集合视图为XIB,ios,objective-c,iphone,xcode,uistoryboard,Ios,Objective C,Iphone,Xcode,Uistoryboard,所以我在tableViewCell中有一个collectionView 当tableViewCell出现在我的故事板中时,一切都很好 我决定将tableViewCell移动到它自己的XIB,因为故事板落后了。现在它给出了错误-> ****由于未捕获的异常“NSInternalInconsistencyException”,正在终止应用程序,原因:“无法将视图出列。” 种类:UICollectionElementKindCell,标识符为TagCellReview- 必须为标识符注册nib或类,或
知道为什么会这样吗?可能的解决方案?我认为,如果集合视图单元位于故事板中,则需要为其注册类;如果集合视图单元位于xib中,则需要为其注册nib
//For Storyboard
[cell.collectionView registerClass:[TagsCollectionViewCell class] forCellWithReuseIdentifier:@"TagsCollectionViewCell"];
// register nib for XIB
[cell.collectionView registerNib:[UINib nibWithNibName:@"TagsCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"TagsCollectionViewCell"];
您在哪里设计了collectionview单元?xib还是故事板?你忘了在集合视图单元格的nib中设置类。我认为如果你是在xib中设计的,你需要为集合视图单元格注册类和/或为集合视图单元格注册nib。是的!成功了!将collectionViewCell移动到新的XIB并执行[cell.tagsCollectionView注册表项NB:[UINib nibWithNibName:@“TagsCollectionViewCell”捆绑:nil]forCellWithReuseIdentifier:@“TagCell”];你能写一个答案吗,我会为将来的用户做正确的标记!
TagsCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"TagCellReview" forIndexPath:indexPath];
cell.tagLabel.text = [reviewSection.serviceTags objectAtIndex:indexPath.row];
return cell;
//For Storyboard
[cell.collectionView registerClass:[TagsCollectionViewCell class] forCellWithReuseIdentifier:@"TagsCollectionViewCell"];
// register nib for XIB
[cell.collectionView registerNib:[UINib nibWithNibName:@"TagsCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"TagsCollectionViewCell"];