使用 UIGestureRecognizer 子类双击某些特定子视图?
我按照 121 WWDC 2010(高级手势识别)的会议演示找到了一种方法,可以在另一个类(TransformGestureReconizer)上实现所有行为(旋转、缩放、平移),并且一切顺利,并对子视图执行此操作
- (void)viewDidLoad {
[super viewDidLoad];
[self.view addSubview:baseView];
subView1.userInteractionEnabled = YES;
[self addTransformGestureToView:subView1];
}
:我的问题: 我想在双击所需的子视图时执行操作。
因此,如果我添加:
- (void)handleDoubleTap:(UIGestureRecognizer *)gestureRecognizer
我无法选择我的操作提供的视图(例如更改其上的图像) 如果我在主视图上添加:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
我只能处理主视图上的双击,但不能处理子视图,并且只能在 TransformGestureReconizer.h
上执行此操作,但不能选择点击的视图(我认为是因为 UIGestureRecognizer 的子类)。
I followed the session's demo of the 121 WWDC 2010 (Advanced Gesture Recognition) to find a way to have all behaviors (rotate, scale, translate) on an other class (TransformGestureReconizer) and all goes well and do this for the subviews:
- (void)viewDidLoad {
[super viewDidLoad];
[self.view addSubview:baseView];
subView1.userInteractionEnabled = YES;
[self addTransformGestureToView:subView1];
}
Here is my problem :
I would like to have an action when I double tap on a desired subview.
So If I add a :
- (void)handleDoubleTap:(UIGestureRecognizer *)gestureRecognizer
I can't choose which view my action delivers (like changing the image on it)
If I add on the main view:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
I can only handle the double tap on the main view, but not for the subviews and can only do it on the TransformGestureReconizer.h
but then not choose the view tapped ( I think because subclass of UIGestureRecognizer).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了一个解决方案:
I found a solution :