0

I'm using the following code to detect a touch on a table cell image. How would I go about enlarging the image on that touch?

The part I'm stuck on is how would I make the cell.userSubmittedImageView accessible from the myFunction method?

from cellForRowAtIndexPath: method

...
    cell.userSubmittedImageView.userInteractionEnabled = YES;
    cell.userSubmittedImageView.tag = indexPath.row;

    UITapGestureRecognizer *tapped = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(myFunction:)];
    tapped.numberOfTapsRequired = 1;
    [cell.userSubmittedImageView addGestureRecognizer:tapped];

    return cell;  
}
-(void)myFunction :(id) sender
{
    UITapGestureRecognizer *gesture = (UITapGestureRecognizer *) sender;
    NSLog(@"Tag = %d", gesture.view.tag);  
}
4

1 回答 1

2

假设你的userSubmittedImageView是一个UIImageView你可以做

UIImageView * userSubmittedImageView = (UIImageView *)gesture.view;

于 2013-09-13T15:04:01.210 回答