J'ai une vue de collection dans un storyboard avec 4 prototypes de cellules de vue de collection avec les identifiants suivants: "Cell", "NoAlbumSelectedCell", "NoPhotosCell" et "NoVideosCell".Erreur lors de l'utilisation de dequeueReusableCellWithReuseIdentifer
C'est le code que je utilise pour charger les cellules:
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView
cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
if (self.noAlbumSelected) {
return [collectionView dequeueReusableCellWithReuseIdentifier:@"NoAlbumSelectedCell" forIndexPath:indexPath];
}
if ([self.medias count] == 0) {
if ([self.listType isEqualToString:@"photo"]) {
UICollectionViewCell *noPhotosCell = [collectionView dequeueReusableCellWithReuseIdentifier:@"NoPhotosCell" forIndexPath:indexPath];
return noPhotosCell;
} else {
UICollectionViewCell *noVideosCell = [collectionView dequeueReusableCellWithReuseIdentifier:@"NoVideosCell" forIndexPath:indexPath];
return noVideosCell;
}
}
MediaCollectionViewCell *cell = (MediaCollectionViewCell *)[collectionView dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath];
[self configureCell:cell forItemAtIndexPath:indexPath];
return cell;
}
Lorsque je tente d'afficher la cellule « NoPhotosCell », je reçois l'erreur suivante:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'could not dequeue a view of kind: UICollectionElementKindCell with identifier NoPhotosCell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'
J'ai essayé faire un nettoyage et reconstruire.
Cela a fonctionné, mais maintenant ce ne sont pas ramasser le contenu dans les cellules! – pedroremedios
@pedroremedios a changé la première ligne pour correspondre à ce que j'ai pu voir dans votre exemple de code. –