Swipe gesture in iPhone SDK 4.0? [closed]
Question
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?
Solution
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.
OTHER TIPS
There is a new API for this: Refer to this post here.
There are easier ways to handle gestures in iOS 4.0 see:
please download the swipe gesture code from this link:
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];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow