UISwipeGestureRecognizer 手势起点
是否可以从 UISwipeGestureRecognizer 获取手势起点。就像它如何可能在
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch * touch = [touches anyObject];
gestureStartPoint = [touch locationInView:self];
}
Is it possible to get a gesture start point from a UISwipeGestureRecognizer. like how its possible in
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch * touch = [touches anyObject];
gestureStartPoint = [touch locationInView:self];
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
根据 UISwipeGestureRecognizer 文档能:
PS:你真的应该先看看文档,答案在 UISwipeGestureRecognizer 的类参考中,应该不难找到。作为开发人员的一部分就是能够查找信息,Apple 有出色的文档,请使用它!
According to the UISwipeGestureRecognizer documentation you can:
PS: you really should first look at the documentation, the answer was in the class reference of UISwipeGestureRecognizer, shouldn't be hard to find. Part of being a developer is being able to look things up, Apple has excellent documentation, use it!
警告
艾米的回答完全不正确!识别器可能会生成
UIGestureRecognizerStateBegan
,但在滑动时UISwipeGestureRecognizer
会生成UIGestureRecognizerStateEnded
仅代码> 事件。但
touchesBegan:
可以正常工作。问题是,如果它支持用户交互,那么它仅适用于当前视图,您需要将其传递给父视图。WARNING
Amy's answer is totally INCORRECT! Recognizer may generate
UIGestureRecognizerStateBegan
but on swipeUISwipeGestureRecognizer
generatesUIGestureRecognizerStateEnded
event only.But
touchesBegan:
works instead. The problem is if it supports user interaction then it works for current view only and you need to pass it to a parent view.是的,这是可能的。参见下面的代码:
Yes, it is possible. See code below: