开发者_如何学Python
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this questionHow 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?
There is a new API for this: Refer to this post here.
There are easier ways to handle gestures in iOS 4.0 see:
http://developer.apple.com/library/ios/#documentation/EventHandling/Conceptual/EventHandlingiPhoneOS/GestureRecognizers/GestureRecognizers.html
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];
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.
精彩评论