iPhone中CGAffineTransformMakeScale中的zoomfactor值

iPhone中CGAffineTransformMakeScale中的zoomfactor值,iphone,cgaffinetransform,Iphone,Cgaffinetransform,1) 我在UIImageView上进行收缩缩放,我应该如何确定zoomfactor值,因为当zoomfactor值超过0[即负值]时,图像会倾斜,我不希望发生这种情况。如何避免这种情况 2) 是flickring的旋转,不是平滑的旋转?这件事会由你负责吗 CGAffineTransformMakeScale(zoomfactor,zoomfactor)方法 这就是我在代码中所做的: zoomFactor=0;//最初,zoomfactor设置为零 - (void)touchesBegan:(NS

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

2) 是flickring的旋转,不是平滑的旋转?这件事会由你负责吗
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 ..................");
}

谢谢。

如果您能够将应用程序限制在操作系统3.2或更高版本(或者如果它是仅限iPad的应用程序),建议您查看
UIPinchGestureRecognizer
UIGestureRecognizer
类。它们消除了很多痛苦。您可以获取它们返回的缩放或旋转值,并直接将它们输入到
cGraffinetTransform
创建函数中