0
votes

I'm working in small app for iPhone which uses openGL.

The app is supposed to :

Move around the screen with a moving touch. Zoom in/Out by tapping

I'm overwriting this functions to handle the coordinates of the touches and move around the screen with my finger, with success, working perfectly:

  • (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
  • (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
  • (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event

I'm using UIGesture recognizers to double taps, pinch gestures, swipes, counter pinch with success as well, all gestures being detected perfectly.

But I'm having conflicts. Some times for example, I do a double tap and it's recognized correctly, but it's also passed to my touchedMoved function, resulting in erratic movements. Same thing happens with pinch and counter pinch gestures, most of the time they work well in zooming in and out, but some times my touchesMoved function detect the touches as well and moves the screen.

It's a bad practice to overwrite this functions and use UIGesturerecognizer at the same time ?. If not, it's there a way to work with both without conflicts ?

I tried setting setDelaysTouchesBegan and setDelaysTouchesEnded to Yes in my recognizers, but this results in my touches not being passed to none of my overwritten functions!

I was thinking in using UIGestureRecognizer to handle swipes and scrap the overwritten functions to receive touches, and use the value of the swipe to calculate how much move my screen, is it possible ?

1

1 Answers

1
votes

I can't answer for why you sometimes receive spurious touchesMoved: events, but it does sound like you may want to just ditch the overwritten functions and use a UIPanGestureRecognizer to handle moving around the screen.