2010-08-12 71 views

回答

1

基本上你需要覆蓋onTouchesBegan和onTouchesEnded。當它開始時,記錄第一個位置,然後在最後比較最後一次觸摸和第一次觸摸,看它是否更低或更高。

+7

這真的是_not_要做到這一點。由於他使用iOS4,他可以使用爲此目的而製作的新的「UIGestureRecognizer」。 Ohmu的答案更適合。 – 2010-09-28 09:19:38

+0

啊。這很有幫助。謝謝。 – 2010-09-29 02:28:10

6

這裏有一個新的API:請參考這個帖子here

1

請從這個鏈接下載輕掃手勢代碼:

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];