पर संलग्न करना संभव है, मैं अपनी खुद की कक्षा में इशारा पहचानकर्ता संलग्न करने की कोशिश कर रहा हूं जो UILabel के उप-वर्ग है, लेकिन यह काम नहीं करता है। तुम मुझे समझने के लिए कोड में गलत क्या है मदद कर सकते हैंक्या UITAPGestureRecognizer को UILabel subclass
@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
अपने जवाब के लिए धन्यवाद! मैंने दस्तावेज पढ़ने में 24 घंटे बिताए और इस सरल चाल को ध्यान में नहीं रखा। बस उम्मीद है कि यह मेरे लिए उपयोगी था :) – Michael