I've got two arrays:
The problem I have is that all the cells for the second section (feedback videos) are not showing. I'm using a single image for every cell at the moment to try and get it to work.
When logging the count of the arrays, they both show they have items in them.
Here's my collection view code:
#pragma mark - Collection View
- (NSInteger)numberOfSectionsInCollectionView: (UICollectionView *)collectionView
{
return 2;
}
- (NSInteger)collectionView:(UICollectionView *)view numberOfItemsInSection:(NSInteger)section
{
if (section == 1)
{
return [self.feedbackImages count];
}
else if (section ==2 )
{
return [self.feedbackVideos count];
}
return 0;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
ImageCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath];
UIImage *image = [[UIImage alloc] init];
image = [UIImage imageNamed:@"86-camera.png"];
cell.ImageView.image = image;
return cell;
}
Am I missing something here?
Section start with index 0 not 1, change collectionView:numberOfItemsInSection
to:
if (section == 0) //<- change to 0
{
return [self.feedbackImages count];
}
else if (section ==1 ) //<- change to 1
{
return [self.feedbackVideos count];
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.