TableViewCell 中的集合视图作为 XIB

Collection View Within TableViewCell as XIB

所以我在 tableViewCell 中有一个 collectionView。

当 tableViewCell 在我的 Storyboard 中时,一切正常。

我决定将 tableViewCell 移动到它自己的 XIB,因为情节提要滞后。现在它给出了错误 ->

**** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'could not dequeue a view of kind: UICollectionElementKindCell with identifier TagCellReview - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'****

在 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;

知道为什么会这样吗?可能的解决方案?

我认为如果单元格在 Storyboard 中,则需要为集合视图单元格注册 class and/or 如果在 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"];