我有一个接收捏手势的UIView。当我捏它时,似乎pinch事件排队,所以在我已经停止捏之后我仍然收到捏事件。我可以清除事件队列吗?如果有,怎么样?如果不是,我该怎么做以确保我的事件不排队?
我正在iOS 7上的iPad 4上进行测试。
捏合手势用于缩放屏幕上的图像。我注意到当我放大然后开始缩小而不释放屏幕时,事件排队。在开始缩小之前,图像仍会放大一些。我使用此功能根据我的手势缩放图像:
- (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