UIPinchGestureRecognizer を実装しようとしている pdf ベースのアプリケーションに取り組んでいます。ユーザーが 640,960 のデフォルト ビュー サイズに達したときに、ピンチ オフ機能を制限したいと考えています。
私の現在の実装では、ユーザーは無限にピンチイン/ピンチアウトできます。
- (void)pinchZoom:(UIPinchGestureRecognizer *)gestureRecognizer
{
if ([gestureRecognizer state] == UIGestureRecognizerStateBegan || [gestureRecognizer state] == UIGestureRecognizerStateChanged) {
if (!zoomActive) {
zoomActive = YES;
UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panMove:)];
[panGesture setMaximumNumberOfTouches:2];
[panGesture setDelegate:self];
[self addGestureRecognizer:panGesture];
[panGesture release];
}
[gestureRecognizer view].transform = CGAffineTransformScale([[gestureRecognizer view] transform], [gestureRecognizer scale], [gestureRecognizer scale]);
[delegate leavesView:self zoomingCurrentView:[gestureRecognizer scale]];
[gestureRecognizer setScale:1];
}
}
// This method will handle the PAN / MOVE gesture
- (void)panMove:(UIPanGestureRecognizer *)gestureRecognizer
{
if ([gestureRecognizer state] == UIGestureRecognizerStateBegan || [gestureRecognizer state] == UIGestureRecognizerStateChanged) {
CGPoint translation = [gestureRecognizer translationInView:[[gestureRecognizer view] superview]];
[[gestureRecognizer view] setCenter:CGPointMake([[gestureRecognizer view] center].x + translation.x, [[gestureRecognizer view] center].y + translation.y)];
[gestureRecognizer setTranslation:CGPointZero inView:[[gestureRecognizer view] superview]];
}
}
これは私が話しているデフォルトのビューサイズ/スケールです:
これは私が望んでいない、またはピンチアウトで制限したいものです:
なにか提案を?