xcode iPhone SDK 4.0 中的滑动手势?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3464439/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Swipe gesture in iPhone SDK 4.0?
提问by NextRev
How do i put a swipe gesture in the new iPhone SDK? I'm trying to detect a swipe gesture over a UIImageView? A swipe up and a swipe down?
如何在新的 iPhone SDK 中放置滑动手势?我正在尝试检测 UIImageView 上的滑动手势?向上滑动和向下滑动?
采纳答案by Matt Williamson
Basically you need to override onTouchesBegan and onTouchesEnded. When it begins, record the first position, then at the end compare the last touch to the first touch to see if it is lower or higher.
基本上你需要覆盖 onTouchesBegan 和 onTouchesEnded。当它开始时,记录第一个位置,然后在最后比较最后一次触摸和第一次触摸,看看它是低还是高。
回答by Justin Tanner
There are easier ways to handle gestures in iOS 4.0 see:
在 iOS 4.0 中有更简单的方法来处理手势,请参阅:
回答by Jaspreet Singh
please download the swipe gesture code from this link:
请从此链接下载滑动手势代码:
https://github.com/brow/leaves/downloads
https://github.com/brow/leaves/downloads
UISwipeGestureRecognizer *settingbtnpress =
[[UISwipeGestureRecognizer alloc]
initWithTarget:self
action:@selector(MethodName)];
settingbtnpress.delegate=self;
settingbtnpress.direction = UISwipeGestureRecognizerDirectionRight;
[self.view addGestureRecognizer:settingbtnpress];
[settingbtnpress release];