-1

1)我在 UIImageView 上进行捏缩放,我应该如何决定 zoomfactor 值,因为当 zoomfactor 值超过 0[即负值]时,图像会倾斜,我不希望它发生。如何避免这种情况。

2) Y 是正在发生的闪烁式旋转,Y 不是平滑旋转?这会通过 CGAffineTransformMakeScale(zoomfactor,zoomfactor);方法来处理吗?

这就是我在我的代码中所做的: zoomFactor = 0;// 最初 zoomfactor 设置为零

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
    NSLog(@" Inside touchesBegan ..................");

    NSArray *twoTouches = [touches allObjects];
    UITouch *first = [twoTouches objectAtIndex:0];

    OPERATION = [self identifyOperation:touches :first];
    NSLog(@"OPERATION : %d",OPERATION);
    if(OPERATION == OPERATION_PINCH){
        //double touch pinch
        UITouch *second = [twoTouches objectAtIndex:1];
        f_G_initialDistance = distanceBetweenPoints([first locationInView:self.view],[second locationInView:self.view]);
    }
    NSLog(@" leaving touchesBegan ..................");
}

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    NSLog(@" Inside touchesMoved .................");

    NSArray *twoTouchPoints = [touches allObjects];
    if(OPERATION == OPERATION_PINCH){

        CGFloat currentDistance = distanceBetweenPoints([[twoTouchPoints objectAtIndex:0] locationInView:self.view],[[twoTouchPoints objectAtIndex:1] locationInView:self.view]);
        int pinchOperation = [self identifyPinchOperation:f_G_initialDistance :currentDistance];
        G_zoomFactor = [self calculateZoomFactor:pinchOperation :G_zoomFactor];
        [uiImageView_G_obj setTransform:CGAffineTransformMakeScale(G_zoomFactor, G_zoomFactor)];

        [self.view bringSubviewToFront:resetButton];
        [self.view bringSubviewToFront:uiSlider_G_obj];

        f_G_initialDistance = currentDistance;
    }

    NSLog(@" leaving touchesMoved ..................");
}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
    NSLog(@" Inside touchesEnded ..................");

    NSArray *twoTouches = [touches allObjects];
    UITouch *first = [twoTouches objectAtIndex:0];

    if(OPERATION == OPERATION_PINCH){
        //do nothing
    }
    NSLog(@" Leaving touchesEnded ..................");
}

谢谢你。

4

1 回答 1

0

如果您能够将您的应用程序限制为 OS 3.2 或更高版本(或者如果它是一个仅限 iPad 的应用程序),建议您看看UIPinchGestureRecognizerUIGestureRecognizer课程。他们带走了很多痛苦。您可以将它们返回的比例或旋转值直接输入到CGAffineTransform创建函数中。

于 2010-06-04T09:37:27.187 回答