【发布时间】:2016-05-13 07:32:09
【问题描述】:
所以我在 tableViewCell 中有一个 collectionView。
当 tableViewCell 在我的情节提要中时,一切正常。
我决定将 tableViewCell 移动到它自己的 XIB,因为情节提要滞后。现在它给出了错误->
**** 由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“无法使视图出队 种类:带有标识符 TagCellReview 的 UICollectionElementKindCell - 必须为标识符注册一个 nib 或一个类或连接一个 故事板中的原型单元格****
在 CellForRowAtIndexPathTableView 中 -->
static NSString *CellIdentifier = @"FeedReviewCell";
ReviewTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
// Configure the cell...
if (cell == nil) {
NSArray *customCell = [[NSBundle mainBundle] loadNibNamed:@"ReviewTableViewCell" owner:self options:nil];
cell = [customCell objectAtIndex:0];
cell.backgroundColor=[UIColor clearColor];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
cell.tagsCollectionView.delegate = self;
cell.tagsCollectionView.dataSource = self;
cellForItemAtIndexPath 集合视图 -->
TagsCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"TagCellReview" forIndexPath:indexPath];
cell.tagLabel.text = [reviewSection.serviceTags objectAtIndex:indexPath.row];
return cell;
知道为什么会这样吗?可能的解决方案?
【问题讨论】:
-
你的collectionview单元是在哪里设计的? xib 还是故事板?
-
您忘记在 Collection 视图单元格的 nib 中设置类
-
如果您在 xib 中设计,我认为您需要为集合视图单元注册类和/或为集合视图单元注册 nib。
-
是的!那行得通!将 collectionViewCell 移动到新的 XIB 并做了 [cell.tagsCollectionView registerNib:[UINib nibWithNibName:@"TagsCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"TagCell"];
-
你能写一个答案吗,我会为以后的用户标记它是正确的!
标签: ios objective-c iphone xcode uistoryboard