Gesture recognition with UIWebView

前端 未结 6 1397
孤街浪徒
孤街浪徒 2021-02-04 10:58

I have set up some gesture recognition in an app that I\'m building. One of the gestures is a single finger single tap, which hides the toolbar at the top of the screen. Works g

6条回答
  •  礼貌的吻别
    2021-02-04 11:40

    I was having the same problem. This solution worked for me:

    1) make sure to add the protocol to your interface: UIGestureRecognizerDelegate for example:

    @interface ViewController : UIViewController _SlideViewProtocol, UIGestureRecognizerDelegate_
    

    2) add this line of code

        - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
    }
    

    3)

    UISwipeGestureRecognizer *swipeGesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(nextSlide)];
            swipeGesture.numberOfTouchesRequired = 1;
            swipeGesture.direction = (UISwipeGestureRecognizerDirectionLeft);
            swipeGesture.cancelsTouchesInView = YES;
            [swipeGesture setDelegate:self];
            [self.view addGestureRecognizer:swipeGesture];
    

提交回复
热议问题