2010-06-04 2 views
0

1) Je fais un zoom de pincement sur le UIImageView, comment devrais-je décider de la valeur de zoomfactor, parce que lorsque la valeur de zoomfactor dépasse 0 [valeur négative] l'image est inclinée, Je ne veux pas que ça arrive. comment éviter cette situation.valeur zoomfactor dans CGAffineTransformMakeScale dans iPhone

2) Y est le type de rotation de flicking qui se passe, Y pas la rotation lisse? Ce procédé sera-t-il pris en charge par la méthode CGAffineTransformMakeScale(zoomfactor,zoomfactor);?

C'est ce que je fais dans mon code: zoomFactor = 0; // Dans un premier temps zoomFactor est mis à zéro

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

Merci.

Répondre

0

Si vous êtes en mesure de limiter votre application à OS 3.2 ou supérieur (ou s'il s'agit d'une application pour iPad uniquement), vous pouvez consulter les classes UIPinchGestureRecognizer et UIGestureRecognizer. Ils enlèvent beaucoup de la douleur. Vous pouvez prendre les valeurs d'échelle ou de rotation qu'ils renvoient et les alimenter directement dans une fonction de création CGAffineTransform.

Questions connexes