0
votes

I'm trying to add a very simple swipe up gesture to one of my views. The gesture does not work at all unless I apply an outward/opposite pinch gesture with two of my fingers. I am creating the gesture connections via IB. I have set up the gesture properties to Swipe: Down and Touches: 1. However it will only work with a 2 finger outward pinching motion? What is going on? Thanks.

Edit:

Ok, I've tried coding it out rather than using interface builder and I'm getting the same results. Here is the code I'm using

    UISwipeGestureRecognizer *swipeUpOnVideoView = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(SwipeUp:)];
swipeUpOnVideoView.direction = UISwipeGestureRecognizerDirectionUp;
swipeUpOnVideoView.numberOfTouchesRequired = 1;
[self.playerView addGestureRecognizer:swipeUpOnVideoView];

As you can see I am specifically designating only 1 touch, however my SwipeUp: method will only execute if I use an outward pinching motion with two fingers???

2
Are you using a UISwipeGestureRecogniser? - Infinity James
Hi, yes. That's what's confusing to me. I am using the UISwipeGestureRecognizer, not the pinchGestureRecognizer as you would expect with my problem. - DavidNorman
How about removing it from the Storyboard or Xib and adding it via code. Try that and see if it helps. - Infinity James

2 Answers

0
votes

check this it working proper in my application:

 UISwipeGestureRecognizer *swipeUp = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeUp:)];
[swipeUp setDirection:UISwipeGestureRecognizerDirectionUp ];
[self.view addGestureRecognizer:swipeUp];

- (IBAction)swipeUp:(UISwipeGestureRecognizer *)recognizer
{
    // do you stuff here
}

May be it will help you.

Happy coding...:)

0
votes

It turned out I had a number of other UITapGestureRecognizers that were on my Xib file. Even though I wasn't calling them in the code anywhere they were associated with views on my page via the connections inspector. For some reason this interference made it so that my single finger swipeGesture would only register if I used a two finger pinching motion.

Deleting multiple UITapGestureRecognizers from my xib and then writing the code for the UISwipeGestureRecognizer programmatically fixed the problem for me.