J'ai un TagCollectionViewCell personnalisé qui est un UICollectionViewCell personnalisé. Dans les jours .xib, j'avais l'habitude d'instancier via UINib mais maintenant, en utilisant Storyboard, je suis complètement désemparé.Problème CollectionViewCell. Du .xib à la transition du storyboard pour la collection personnalisée viewviewcell
\t UINib *cellNib = [UINib nibWithNibName:@"TagCollectionViewCell" bundle:nil];
\t [self.collectionView registerNib:cellNib forCellWithReuseIdentifier:@"TagCell"];
\t
\t
\t _sizingCell = [[cellNib instantiateWithOwner:nil options:nil] objectAtIndex:0];
Dans storyboard J'ai collé la pointe dans le .storyboard, il a donné la classe personnalisée affectée. Mais je reçois un écran blanc. C'est ma cellule de collection personnalisée que je veux dans le storyboard.
Quels changements dois-je faire dans la vue de collection cell_for_item_atindexpath. Le code pour .xib était le suivant.
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
\t TagCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"TagCell" forIndexPath:indexPath];
\t
\t [self _configureCell:cell forIndexPath:indexPath];
\t
\t return cell;
}
et pour configurer la mise en page était cela.
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
\t [self _configureCell:_sizingCell forIndexPath:indexPath];
\t
\t return [_sizingCell systemLayoutSizeFittingSize:UILayoutFittingCompressedSize];
}
Salut. Voir ma réponse ci-dessous – LearneriOS