开发者

Swipe gesture in iPhone SDK 4.0? [closed]

开发者 https://www.devze.com 2023-01-11 09:43 出处:网络
Closed. This question needs to be more focused. It is not currently accepting answers. 开发者_如何学Python
Closed. This question needs to be more focused. It is not currently accepting answers.
开发者_如何学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 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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消