简体   繁体   中英

How to enlarge uitableview cell image on touch

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);  
}

假设您的userSubmittedImageViewUIImageView,您可以这样做

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM