0
如何識別UISwipeGestureRecognizer
與UISwipeGestureRecognizerDirectionUp
,然後直接在此之後,無需擡起手指,識別出UISwipeGestureRecognizerDirectionDown
識別器?UISwipeGestureRecognizer不會掉下來
基本上我想要多個UISwipeGestureRecognizers
在我改變方向時不會擡起手指。
到目前爲止我的代碼...
- (void)viewDidLoad {
UISwipeGestureRecognizer *swipeUp = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(screenSwipedUp)];
swipeUp.numberOfTouchesRequired = 1;
swipeUp.direction = UISwipeGestureRecognizerDirectionUp;
swipeUp.cancelsTouchesInView = NO;
[self.view addGestureRecognizer:swipeUp];
UISwipeGestureRecognizer *swipeDown = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(screenSwipedDown)];
swipeDown.numberOfTouchesRequired = 1;
swipeDown.direction = UISwipeGestureRecognizerDirectionDown;
swipeDown.cancelsTouchesInView = NO;
[self.view addGestureRecognizer:swipeDown];
}
- (void)screenSwipedUp {
NSLog(@"SW-Up");
}
- (void)screenSwipedDown {
NSLog(@"SW-Down");
}
我想你試圖實現'拖動'而不是'刷卡'? – iphonic
'UIPanGestureRecognizer'是正確的工具。還有一些庫提供了複雜手勢的識別(谷歌「iOS手勢識別器形狀」或「iOS手勢識別器複合體」),但這很簡單,我傾向於在我自己的平底鍋中自己檢測它手勢識別器。 – Rob