2010-06-04 16 views
0

1)我在UIImageView上縮放縮放,我應該如何決定縮放因子的值,因爲當縮放因子值超過0 [即負值]圖像是gettig傾斜的,我不希望它發生。如何避免這種情況。在CGAffineTransformMakeScale中的zoomfactor值iPhone

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 .................."); 
} 

謝謝。

回答

0

如果您可以將您的應用程序限制爲OS 3.2或更高版本(或者它是僅iPad應用程序),建議您查看UIPinchGestureRecognizerUIGestureRecognizer課程。他們帶走了很多痛苦。您可以獲取它們返回的比例或旋轉值,並直接將它們輸入CGAffineTransform創建函數。

相關問題