Estoy intentando adjuntar el reconocedor de gestos a mi propia clase, que es la subclase de UILabel, pero no funciona. ¿Puede ayudarme a entender lo que está mal en el códigoEs posible adjuntar UITapGestureRecognizer a la subclase UILabel
@interface Card : UILabel {
}
- (void) addBackSideWord;
@end
#import "Card.h"
@implementation Card
- (id)initWithFrame:(CGRect)frame {
if ((self = [super initWithFrame:frame])) {
UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc]
initWithTarget:self action:@selector(addBackSideWord)];
[tapRecognizer setNumberOfTouchesRequired:2];
[tapRecognizer setDelegate:self];
[self addGestureRecognizer:tapRecognizer];
}
return self;
}
- (void) addBackSideWord {
//do something
}
@end
Gracias por sus respuestas! Pasé 24 horas leyendo documentación y no noté este simple truco. Solo espero que me haya sido útil :) – Michael