0

I have a UIView that receives pinch gestures. When I pinch it, it seems like the pinch events queue up, so I still receive pinch events after I already stopped pinching. Can I clear the event queue? If yes, how? If no, what can I do to make sure my events don't queue up?

I'm testing on an iPad 4, on iOS 7.

The pinching gesture is used to zoom an image on screen. I notice that the events queue up when I zoom in and then start zooming out without releasing the screen. The image still zooms in a bit more before starting to zoom out. I use this function to zoom the image according to my gestures:

- (IBAction)pinch:(id)sender {
    NSLog(@"zooming");
    float s = [(UIPinchGestureRecognizer*)sender scale];
    s+=0.9*(1-s);

    CATransform3D old = photoView.layer.transform;

    //limit to 128*128 minimum
    if (photoView.frame.size.width * s < 128) s=(float)128/photoView.frame.size.width;
    if (photoView.frame.size.height * s < 128) s=(float)128/photoView.frame.size.height;

    //limit to 768*768 maximum
    if (photoView.frame.size.width * s > 768) s=(float)768/photoView.frame.size.width;
    if (photoView.frame.size.height * s > 768) s=(float)768/photoView.frame.size.height;

    CATransform3D new = CATransform3DScale(old,s,s,1);
    photoView.layer.transform = new;
}

//logs
2014-02-27 16:28:10.728 Medicatie Controle App[338:60b] zooming started
2014-02-27 16:28:10.730 Medicatie Controle App[338:60b] zooming ended
2014-02-27 16:28:10.745 Medicatie Controle App[338:60b] zooming started
2014-02-27 16:28:10.746 Medicatie Controle App[338:60b] zooming ended
2014-02-27 16:28:10.746 Medicatie Controle App[338:60b] zooming started
Kevin
  • 2,739
  • 33
  • 57

0 Answers0