1

我正在开发基于 pdf 的应用程序,我正在尝试实现 UIPinchGestureRecognizer。当用户达到 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]];   
    }  
}

这是我正在谈论的默认视图大小/比例:默认pdf

这是我不想要的或者我想限制的:
无限捏出

有什么建议吗?

4

2 回答 2

3

在处理程序函数中处理自己的下限怎么样?像这样的东西:

- (void)pinchZoom:(UIPinchGestureRecognizer *)gestureRecognizer {

     ....

    if ( [gestureRecognizer scale] > MIN_SCALE )
        [gestureRecognizer view].transform = CGAffineTransformScale([[gestureRecognizer view] transform], [gestureRecognizer scale], [gestureRecognizer scale]);
  ...
于 2012-06-04T15:06:44.333 回答
2

在您的手势识别器中,您将必须测试和了解 PDF 视图的当前比例/大小,并且在您占据全屏时不要缩小。

于 2012-06-04T15:08:06.253 回答