1
votes

I want to perform a seque from a UICollectionViewCell inside a UICollectionView. There is a UIIMage that is a subview of UICollectionView. There is a button which is a peer view of UICollectionViewCell. I have used the workarround of a transparent button on top of UIIMage to capture touch events on this cell. Now I want to perform a segue when the user clicks this Image on the collection cell. The problem is that I dont know which cell's button triggered the segue and handle it in prepare for segue.

The button triggers an IBAction where the sender is this button. How do I know which cell is its UICollectionCell underneath this transperent button ?

2

2 Answers

1
votes

add tags to your buttons and perform different segues depending on the tags. Another way - without buttons would be to add tap gestures to your UIImages and perform segues depending on which image has been tapped ...

0
votes

Found the solution: Its similar to the one solved for tableview (of course given UICollectionView is a repackaged table view) posted here.

The solution is to use

-(void)buttonPressed:(id)sender {
 UITableViewCell *clickedCell = (UITableViewCell *)[[sender superview] superview];
 NSIndexPath *clickedButtonPath = [self.tableView indexPathForCell:clickedCell];
...

}