0

我如何识别一个UISwipeGestureRecognizerUISwipeGestureRecognizerDirectionUp然后直接在不抬起手指的情况下识别一个UISwipeGestureRecognizerDirectionDown识别器?

基本上,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");
    }
4

1 回答 1

1

我不认为你可以用UISwipeGestureRecognizer做到这一点。您可以改为使用UIPanGestureRecognizer并实现该操作或创建UIGestureRecognizer的子类并覆盖方法以识别您的特殊手势。

于 2013-04-14T10:29:14.420 回答