How to tell the difference between touchesBegan and touchesMoved

823 views Asked by At

How can I ignore the touchesBegan method when the user is pinching an object and ignore the touchesMoved method when the user taps on the screen? I created a picture zoom in / zoom out effect and I want to be able to hide the navigation bar when the user taps on the screen once. Right now when the user starts pinching, the navigation bar gets displayed since the user touched once.

What would be the best way to do this?

1

There are 1 answers

0
Christopher Pickslay On BEST ANSWER

It seems like the easiest thing to do for your show/hide navigation bar would be to add a UITapGestureRecognizer and set numberOfTouchesRequired and numberOfTapsRequired to 1.

Alternatively, you could use touchesEnded instead of touchesBegan. Then in your touchesEnded, you could check for the number of touches and only show/hide if it's 1:

-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { 
    UITouch *theTouch = [touches anyObject]; 
    if (theTouch.tapCount == 1) {
        // show/hide navigation here ...
    } else {
        // finish your zoom here ...
    }
}