I have a CollectionView
setup that displays remote image data from server. I am able to view the images in the CollectionView
, but nothing shows when I tap the item for the DetailView
. It was working properly while I used local images, but after adding the "SDWebImage framework", I am unable to view the images when I tap them for DetailView
. I believe the issue lies with the prepareForSegue
method, but nothing I have tried will solve the issue. I have searched many questions on "StackOverflow", but was unable to find an answer for this specific issue.
Here is my code for CollectionViewController
:
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
static NSString *identifier = @"Cell";
CollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];
[cell.thumbnailView setImageWithURL:[NSURL URLWithString:[photos objectAtIndex:indexPath.row]] placeholderImage:[UIImage imageNamed:@"logo.png"] options:SDWebImageRefreshCached];
return cell;
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"displayDetail"]) {
PhotoViewController *destViewController = (PhotoViewController *)segue.destinationViewController;
NSIndexPath *indexPath = [self.collectionView indexPathForCell:sender];
NSString *imagePath = [photos objectAtIndex:indexPath.row];
UIImage *image = [UIImage imageNamed:imagePath];
NSLog(@"Image named: %@ at row %ld", imagePath, (long)indexPath.row);
destViewController.largeImage = image;
}
}
The segue triggers fine, but just displays a white screen in PhotoViewController.m
after being tapped.