-2

I am trying to use two TapGestures on two labels, but it always shows the result of last one TapGesture. My code is as follows:

 [write_review_label addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(open_view:)]];
[map_image addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(open_view:)]];
write_review_label.tag = 1;
map_image.tag = 2;

-(void)open_view:(UITapGestureRecognizer *)recog1
{
NSLog( @"recog1.view.tag == %d",recog1.view.tag);
if (recog1.view.tag==2)
{
    [self performSegueWithIdentifier:@"mapsegue" sender:self];
}
else
    [self performSegueWithIdentifier:@"loginsegue" sender:self];
 }
tshepang
  • 12,111
  • 21
  • 91
  • 136
Kamal Bhardwaj
  • 948
  • 1
  • 10
  • 25

2 Answers2

0

By default User interaction is disable for label and imageview,

make it enabled.

[write_review_label setUserInteractionEnabled:YES];   
[map_image setUserInteractionEnabled:YES];
Toseef Khilji
  • 17,192
  • 12
  • 80
  • 121
0

You need to enable user interaction of labels like:

write_review_label.userInteractionEnabled = YES;
map_image.userInteractionEnabled = YES;
Abdullah Md. Zubair
  • 3,312
  • 2
  • 30
  • 39