1

I am trying to figure out how to change the view in a UICollectionViewCell that triggers the UICollectionView's didSelectCellAtIndexPath. I want to have a top layer that can be tapped to activate, or panned to reveal a lower layer of buttons.

I can add a view on top, and achieve the pan to reveal gesture, but I have to tap the underlying view to trigger didSelect.

Also, I am not using xib's or storyboards, this is all in code.

Any Ideas?

Gabriel.Massana
  • 8,165
  • 6
  • 62
  • 81
Weston
  • 1,481
  • 1
  • 11
  • 31
  • take a look here: http://stackoverflow.com/questions/15681765/how-to-pass-gestures-from-uitextview-to-uicollectionviewcell – peko Apr 23 '13 at 16:04

1 Answers1

0

Thanks to @peko, I figured it out.

- (void)selectCell {
    UICollectionView *collectionView = (UICollectionView *)self.superview;
    NSIndexPath *indexPath = [collectionView indexPathForCell:self];
    [collectionView.delegate collectionView:collectionView didSelectItemAtIndexPath:indexPath];
}

This allows me to simulate selection of the cell from within the view controller.

Weston
  • 1,481
  • 1
  • 11
  • 31