当我使用下面的方法捏缩放时,有时videoZoomFactor将低于1,应用程序将崩溃。如何修改我的方法,以便当我尝试缩放到最小值时,缩放系数不会低于1.我正在寻找自然缩放而不是简单地将夹点比例因子添加到1。
-(void) handlePinchToZoomRecognizer:(UIPinchGestureRecognizer*)pinchRecognizer {
const CGFloat pinchVelocityDividerFactor = 5.0f;
NSLog(@"%f", atan(pinchRecognizer.velocity / pinchVelocityDividerFactor));
if (pinchRecognizer.state == UIGestureRecognizerStateChanged) {
NSError *error = nil;
if ([inputDevice lockForConfiguration:&error]) {
inputDevice.videoZoomFactor = inputDevice.videoZoomFactor + atan(pinchRecognizer.velocity / pinchVelocityDividerFactor);
[inputDevice unlockForConfiguration];
} else {
NSLog(@"error: %@", error);
}
}
}