如何给uiimageview添加点击事件
展开全部
给的UIImageView增加点击事件
解决思路1:网友提示在该“button”上增加一个真正的透明button,这样就可以顺利执行点击事件了;但是本人尝试发现,如果我调整了button的透明度后,点击是没有效果的!可能是我操作错误,待再次验证。
解决思路2:为的UIImageView增加手势
[ImageView的addGestureRecognizer:我们自己的手势识别 ]
如何创建一个手势?看看UITapGestureRecognizer的用法吧
//单指单击
2: UITapGestureRecognizer * singleFingerOne = [[UITapGestureRecognizer页头] initWithTarget:自
3: 操作:@selector(handleSingleFingerEvent :)]
4: singleFingerOne.numberOfTouchesRequired = 1; //手指数
5: singleFingerOne.numberOfTapsRequired = 1; //抽头次数
6 。singleFingerOne 委托 =自我;
7:
8: //单指双击
9: UITapGestureRecognizer * singleFingerTwo = [[UITapGestureRecognizer页头] initWithTarget:自
10: 操作:@selector(handleSingleFingerEvent :)];
11: singleFingerTwo.numberOfTouchesRequired = 1;
12: singleFingerTwo.numberOfTapsRequired = 2;
13: 。singleFingerTwo 委托 =自我;
14:
15: //双指单击
16: UITapGestureRecognizer * doubleFingerOne = [[UITapGestureRecognizer页头] initWithTarget:自
17: 操作:@selector(handleDoubleFingerEvent :)];
18: doubleFingerOne.numberOfTouchesRequired = 2;
19: doubleFingerOne.numberOfTapsRequired = 1;
20: 。doubleFingerOne 委托 =自我;
21:
22: UITapGestureRecognizer * doubleFingerTwo = [[UITapGestureRecognizer页头] initWithTarget:自
23: 操作:@selector(handleDoubleFingerEvent :)];
24: doubleFingerTwo.numberOfTouchesRequired = 2;
25: doubleFingerTwo.numberOfTapsRequired = 2;
26: 。doubleFingerTwo 委托 =自我;
27:
28: //如果不加下面的话,当单指双击时,会先调用单指单击中的处理,再调用单指双击中的处理
29: [singleFingerOne requireGestureRecognizerToFail:singleFingerTwo]
30: //同理双指亦是如此
解决思路1:网友提示在该“button”上增加一个真正的透明button,这样就可以顺利执行点击事件了;但是本人尝试发现,如果我调整了button的透明度后,点击是没有效果的!可能是我操作错误,待再次验证。
解决思路2:为的UIImageView增加手势
[ImageView的addGestureRecognizer:我们自己的手势识别 ]
如何创建一个手势?看看UITapGestureRecognizer的用法吧
//单指单击
2: UITapGestureRecognizer * singleFingerOne = [[UITapGestureRecognizer页头] initWithTarget:自
3: 操作:@selector(handleSingleFingerEvent :)]
4: singleFingerOne.numberOfTouchesRequired = 1; //手指数
5: singleFingerOne.numberOfTapsRequired = 1; //抽头次数
6 。singleFingerOne 委托 =自我;
7:
8: //单指双击
9: UITapGestureRecognizer * singleFingerTwo = [[UITapGestureRecognizer页头] initWithTarget:自
10: 操作:@selector(handleSingleFingerEvent :)];
11: singleFingerTwo.numberOfTouchesRequired = 1;
12: singleFingerTwo.numberOfTapsRequired = 2;
13: 。singleFingerTwo 委托 =自我;
14:
15: //双指单击
16: UITapGestureRecognizer * doubleFingerOne = [[UITapGestureRecognizer页头] initWithTarget:自
17: 操作:@selector(handleDoubleFingerEvent :)];
18: doubleFingerOne.numberOfTouchesRequired = 2;
19: doubleFingerOne.numberOfTapsRequired = 1;
20: 。doubleFingerOne 委托 =自我;
21:
22: UITapGestureRecognizer * doubleFingerTwo = [[UITapGestureRecognizer页头] initWithTarget:自
23: 操作:@selector(handleDoubleFingerEvent :)];
24: doubleFingerTwo.numberOfTouchesRequired = 2;
25: doubleFingerTwo.numberOfTapsRequired = 2;
26: 。doubleFingerTwo 委托 =自我;
27:
28: //如果不加下面的话,当单指双击时,会先调用单指单击中的处理,再调用单指双击中的处理
29: [singleFingerOne requireGestureRecognizerToFail:singleFingerTwo]
30: //同理双指亦是如此
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询