tapGesture 不适用于标签
Posted
技术标签:
【中文标题】tapGesture 不适用于标签【英文标题】:tapGesture is not working for labels 【发布时间】:2013-12-11 09:08:41 【问题描述】:UITapGestureRecognizer *tapGesture1 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(openNewView:)];
UITapGestureRecognizer *tapGesture2 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(openNewView:)];
[writeReview_view setTag:1];
[map_view setTag:2];
[writeReview_view addGestureRecognizer:tapGesture1];
[map_view addGestureRecognizer:tapGesture2];
-(void)openNewView:(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];
【问题讨论】:
【参考方案1】:在标签上启用 userInteractionEnabled
label.userInteractionEnabled = YES;
【讨论】:
以上是关于tapGesture 不适用于标签的主要内容,如果未能解决你的问题,请参考以下文章
如何使用 tapGesture (Xamarin.Forms) 从应用程序中的多个标签中删除选定的标签