Detect Touch on UILabel
In one situation i want to detect touch on my Label, so i want to share the code :
- (void)viewDidLoad
{
[super viewDidLoad];
UITapGestureRecognizer *taplabelGesture = [[UITapGestureRecognizer alloc]
initWithTarget:self
action:@selector(gestureTap)];
UILabel *label = @"Suraj Mirajkar";
[label setFrame: CGRectMake(5o, 50, 100, 80)];
[self.view addSubview: label];
label .userInteractionEnabled
= YES;
[label addGestureRecognizer:taplabelGesture];
[taplabelGesture release];
}
-(void)
gestureTap
{
NSLog("Hey, you detected touch on Label");
}
Comments
Post a Comment