您的位置:首页 > 其它

关于手势 — 手势添加tag值

2016-03-21 16:31 281 查看
当我们定义了多个手势得时候,就需要对收拾做一些区分,当然不区分,每个手势定义一个方法名也是可以的,就是麻烦,所以···

通常我们是给控件加tag值来区分的,当然,手势没有自带的tag属性,但是手势所属的view具有tag属性, 

UITapGestureRecognizer *tapGeture1 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(buttonJump:)];
tapGeture1.delegate = self;
[_bView1 addGestureRecognizer:tapGeture1];
UIView *tapView1 = [tapGeture1 view];
tapView1.tag = 151;

UITapGestureRecognizer *tapGeture3 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(buttonJump:)];
tapGeture3.delegate = self;
[_bView3 addGestureRecognizer:tapGeture3];
UIView *tapView3 = [tapGeture3 view];
tapView3.tag = 153;


手势方法中实现如下

- (void)buttonJump:(UITapGestureRecognizer *)tapGesture{

UITapGestureRecognizer *singleTap = (UITapGestureRecognizer *)tapGesture;
NSInteger index = singleTap.view.tag;
switch (index) {
case 151:{
ActivitySignUpViewController *actSignUpVC = [[ActivitySignUpViewController alloc]initWithNibName:@"ActivitySignUpViewController" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:actSignUpVC animated:YES];
break;
}
default:
break;
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  手势