Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't see my UICollectionViewCells
    primarykey
    data
    text
    <p>I'm writing an app with a UICollectionViewController.</p> <p>I've created the layout in with a storyboard. Subclassed UICollectionViewController and linked the two in IB. I've also given it a Storyboard ID of "ImageCollectionViewController".</p> <p>I've also subclassed a UICollectionViewCell and linked it with my prototype cell in IB as well as given it the Identifier "ImageCell".</p> <p>This is my constructor I call to create my custom UICollectionViewController:</p> <pre><code>-(id)initWithGroup:(CatalogGroup*)group { UIStoryboard* storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPad" bundle: nil]; self = [storyboard instantiateViewControllerWithIdentifier:@"ImageCollectionViewController"]; if (self) { [self setGroup:group]; // Register the type of cell for collection view [self.collectionView registerClass:[ImageCell class] forCellWithReuseIdentifier:@"ImageCell"]; } return self; } </code></pre> <p>Now this all seems to work. All the delegate methods are being called in the collectionViewController. For example:</p> <pre><code>-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { id &lt;NSFetchedResultsSectionInfo&gt; sectionInfo = [[self fetchedResultsController] sections][section]; return [sectionInfo numberOfObjects]; } </code></pre> <p>My cells are being initialized and passed back with:</p> <pre><code>-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { static NSString* identifier = @"ImageCell"; ImageCell* cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath]; ImageItem* item = [[self fetchedResultsController].fetchedObjects objectAtIndex:indexPath.row]; if(cell) { // Set up label cell.label.lineBreakMode = NSLineBreakByCharWrapping; cell.label.numberOfLines = 0; [cell.label setText:item.labelText]; NSData* imageData = item.imageData; UIImage* image = [UIImage imageWithData:imageData]; UIImageView* imageView = [[UIImageView alloc] initWithImage:image]; [cell setImageView:imageView]; } return cell; } </code></pre> <p>Yet when I push the view controller onto the stack. None of the cells are there? Is there anything wrong with my stack? </p> <p>The background color I set for the CollectionView in IB is showing so I believe it's being created properly. The cells are initialized. The delegate methods are being called so I don't know where to start debugging.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload