Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Indexpath of the button from UICollectionView

I tried to:

- (IBAction)delete:(UIButton*)sender{
    NSIndexPath *indexPath = [self.collectionView indexPathForCell:(TourGridCell *)[[[sender superview]superview]superview]];
}

But NSLog shows that cell exist, but indexpath is nil.

like image 379
Shmidt Avatar asked Sep 25 '12 09:09

Shmidt


1 Answers

OK, here it is:

- (IBAction)delete:(UIButton *)sender{
    NSIndexPath *indexPath = nil;
    indexPath = [self.collectionView indexPathForItemAtPoint:[self.collectionView convertPoint:sender.center fromView:sender.superview]];
}
like image 122
Shmidt Avatar answered Oct 14 '22 00:10

Shmidt