2016-05-13 10 views
0

だから私はtableViewCellにcollectionViewを持っています。コレクションビュー内のTableViewCellとしてXIB

tableViewCellが私のストーリーボードにあったときに、すべてうまくいきました。

私は、ストーリーボードが遅れていたので、独自のXIBにtableViewCellを移動することに決めました。今ではエラーになります - >

****キャッチされない例外「NSInternalInconsistencyException」に起因するアプリを終了、理由:「種類のビュー をデキューできませんでした:識別子TagCellReviewとUICollectionElementKindCell - は、ペン先を登録する必要がありますか識別子のクラスまたはストーリーボードに プロトタイプセルを接続する「**** 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 CollectionView - >

 TagsCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"TagCellReview" forIndexPath:indexPath]; 
     cell.tagLabel.text = [reviewSection.serviceTags objectAtIndex:indexPath.row]; 
     return cell; 

これはどうして起こりますか?可能な解決策?

+0

あなたのコレクションビューセルはどこで設計しましたか? xibまたはストーリーボード? – marosoaie

+0

コレクションビューセルのペンでクラスを設定するのを忘れた –

+0

コレクションビューセルのクラスを登録する必要があると思います。コレクションビューセルのためにnibを登録する必要があると思います。 – Mahesh

答えて

1

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"]; 
関連する問題