2011-11-14 98 views
0

我知道在ios中處理手勢,但是可以爲動作實現DoubleTapGesture嗎? 這意味着iphone中的手勢識別器疑惑

UISwipeGestureRecognizer *swipeGesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeGesture:)]; 
    swipeGesture.direction = UISwipeGestureRecognizerDirectionRight; // or whatever 
    [table addGestureRecognizer:swipeGesture]; 
    [swipeGesture release]; 
    UISwipeGestureRecognizer *swipeGestureleft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeGestureleft:)]; 
    swipeGestureleft.direction = UISwipeGestureRecognizerDirectionLeft; // or whatever 
    [table addGestureRecognizer:swipeGestureleft]; 
    [swipeGestureleft release]; 

我們可以通過這種方式做左,右輕掃,但我想DoubleTap姿態不喜歡上面的代碼中的作用。 在此先感謝。

回答

1

您可以爲配置UITapGestureRecognizer:

UITapGestureRecognizer *dblTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleDoubleTap:)]; 
dblTap. numberOfTapsRequired = 2; 
[table addGestureRecognizer:dblTap]; 
[dblTap release]; 
+0

偉大它的作品,還有一個疑問,我可以實現sipeRightHold一個動作是刷卡右然後再保持動作拜?。 – ICoder

+0

不清楚你想要什麼...檢查http://developer.apple.com/library/IOs/#documentation/UIKit/Reference/UIGestureRecognizer_Class/Reference/Reference.html文檔,可能是UILongPressGestureRecognizer是你需要的嗎? .. – Vladimir

+0

是啊,我明白了。謝謝 – ICoder