I have a UICollectionView consisting of numerous cells. I'd like to be able to tap on one of these cells and have my Storyboard segue to another view controller after determining that this is the appropriate action.
I have created my secondary view controller, along with the segue, in my Storyboard. In my UICollectionView subclass, I've implemented the following...
-(BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender {
return NO; // So that I can determine whether or not to perform the segue based on app logic
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
[collectionView deselectItemAtIndexPath:indexPath animated:YES];
// Selection logic here
[self performSegueWithIdentifier:@"showDetailView" sender:self];
}
In this class I also have implemented -(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender to allow me to setup my detail view prior to the segue being performed. It looks like this:
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
NSLog(@"HELLO, WORLD!!!");
}
Everything seems to be in order, but I am finding that prepareForSegue
is NEVER called. I've tried logging, setting breakpoints. There is no indication that this method is EVER called. What am I missing here? Why is this method not being called? While it has a simple "Hello, World" statement now, I previously had code that my detail view depended on and it would result in an exception because the detail view was not setup properly.
Is there something else I'm missing here? Something I should be doing that I am not currently?