The didSelectRowAtIndexPath method didSelectRowAtIndexPath not work in my application. I am not printing any results using NSLog :
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { PhotoCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath]; PFObject *imageObject = [self.imageFilesArray objectAtIndex:indexPath.row]; PFFile *imageFile = [imageObject objectForKey:@"file"]; [imageFile getDataInBackgroundWithBlock:^(NSData *data, NSError *error) { if (!error) { cell.imageView.image = [UIImage imageWithData:data]; } }]; return cell; } - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { PhotoCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath]; NSLog(@"didSelectRowAtIndexPath"); cell.imageView.image = self.image; return cell; }
I would like that when you click on the cell that displays the selected image, and give the image self.image .
Can we do it in segue? Since my didSelectRowAtIndexPath method didSelectRowAtIndexPath not work at all.
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([segue.identifier isEqualToString:@"showPhotoDetail"]) { NSLog(@"SEGUE showPhotoDetail"); UICollectionViewCell *cell = sender; NSIndexPath *indexPath = [self.collectionView indexPathForCell:cell]; PhotoDetailViewController *photoDetailViewController = (PhotoDetailViewController *)segue.destinationViewController; photoDetailViewController.truckImage = self.image;
source share