Questo è in realtà più facile di quanto si pensi. Devi solo assicurarti di abilitare l'interazione dell'utente su imageView e puoi aggiungere un tocco di tocco ad esso. Questo dovrebbe essere fatto quando la cella viene istanziata per evitare di avere più gesti di tocco aggiunti alla stessa vista dell'immagine. Per esempio:
- (instancetype)initWithCoder:(NSCoder *)aDecoder
{
if (self = [super initWithCoder:aDecoder]) {
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(myTapMethod:)];
[self.imageView addGestureRecognizer:tap];
[self.imageView setUserInteractionEnabled:YES];
}
return self;
}
- (void)myTapMethod:(UITapGestureRecognizer *)tapGesture
{
UIImageView *imageView = (UIImageView *)tapGesture.view;
NSLog(@"%@", imageView);
}
fonte
2012-07-20 10:22:16
Aggiungi al tuo UITapGestureRecognizer UIImageView. – robertvojta