iOS:UISwipeGestureRecognizer
我有这样的代码:
UISwipeGestureRecognizer *recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(rightSwipeHandle:)];
[recognizer setNumberOfTouchesRequired:1];
[n16 addGestureRecognizer:recognizer];
[n17 addGestureRecognizer:recognizer];
- (void)rightSwipeHandle:(UISwipeGestureRecognizer*)gestureRecognizer{
NSLog(@"SWIPE");
}
我怎样才能知道什么视图发生了手势?视图为 n16 和 n17
I have this code:
UISwipeGestureRecognizer *recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(rightSwipeHandle:)];
[recognizer setNumberOfTouchesRequired:1];
[n16 addGestureRecognizer:recognizer];
[n17 addGestureRecognizer:recognizer];
- (void)rightSwipeHandle:(UISwipeGestureRecognizer*)gestureRecognizer{
NSLog(@"SWIPE");
}
How can I know what view happens gesture? views are n16 and n17
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不确定您是否可以将相同的 UIGestureRecognizer 实例注册到不同的视图,但如果可以,我认为 UIGestureRecognizer.view 属性就是您正在寻找的。
http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIGestureRecognizer_Class/Reference/Reference.html#//apple_ref/occ/cl/UIGestureRecognizer
所以,你应该能够做这样的事情。 (同样,我不确定您是否可以将不同的 UIGestureRecognizer 实例附加到不同的视图......)
I am not sure if you can register the same UIGestureRecognizer instance to different views, but if you could, I think UIGestureRecognizer.view property is what you are looking for.
http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIGestureRecognizer_Class/Reference/Reference.html#//apple_ref/occ/cl/UIGestureRecognizer
So, you should be able to do something like this. (again, I am not sure if you can attach different UIGestureRecognizer instance to different views...)
像这样:
Like this: