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?
Asked
Active
Viewed 8,556 times
4 Answers
2
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];

Jaspreet Singh
- 1,180
- 2
- 12
- 30
1
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.

Matt Williamson
- 39,165
- 10
- 64
- 72
-
7This really is _not_ the way to do it. Since he's using iOS4 he can use the new `UIGestureRecognizer` which were made for this purpose. Ohmu's answer is better suited. – ynnckcmprnl Sep 28 '10 at 09:19