Search code examples
iosuicollectionviewuistoryboardsegue

UICollectionView Segue not showing detail VC


I have 2 view controllers - One with a collectionView displaying images, the other it's corresponding detail view - pretty basic. The problems is items in collectionView are not selectable for some reason (touch but nothing happens). Also, I am not using a nav controller to embed the collectionView VC in, prefer to use an unwind segue with custom button - will this work?

I made a connection from the collectionView Cell to the Detail VC.

In prepareForSegue

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    if ([segue.identifier isEqualToString:@"detailSegue"]) {
        LPDiaryDetailViewController *destViewController = segue.destinationViewController;
        NSIndexPath *indexPath = [self.collectionView indexPathForCell:sender];
        LocationImage *image = self.savedItems[indexPath.row];
        destViewController.captionString = image.caption;
    }
}

Solution

  • The cell is probably not responding to touches because you haven't set the image view's userInteractionEnabled property to YES (it's NO by default).

    You can't use an unwind segue to go forward; they're for going back to a previous controller, so your preference to use an unwind segue doesn't make sense. Do you mean for the unwind segue to be used for going back from the detail VC? It's not clear where you want this custom button. You already have the segue connected from the cell, so you don't need a button to invoke the segue.