Shmidt Shmidt - 1 year ago 88
Objective-C Question

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.

Answer Source

OK, here it is:

- (IBAction)delete:(UIButton *)sender{
    NSIndexPath *indexPath = nil;
    indexPath = [self.collectionView indexPathForItemAtPoint:[self.collectionView fromView:sender.superview]];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download