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

Popular posts from this blog

UITableView - Add or Remove Rows Dynamically (Objective C & Swift Source codes)

payUmoney Payment Gateway Integration in iOS App (Objective C)

Check Internet Connectivity Using AFNetworking 2.0