2010-07-03 5 views
0
-(ibaction)sometouched:(id)sender 
{ 
    [UIView beginAnimations:@"first one" context:nil]; 
    [UIView setAnimationDuration:1.0]; 
    [myview setFrame:CGRectMake(0,y,width.height.); 
    [UIView commitAnimations]; 

    [UIView beginAnimations:@"second one" context:nil]; 
    [UIView setAnimationDuration:1.0]; 
    [myview setFrame:CGRectMake(x,0,width.height.); 
    [UIView commitAnimations]; 
} 

Ceci est juste une démonstration. Ce que je veux, c'est que l'animation prendra 2 parties. le premier déplace la vue vers le bas et le second la déplace vers la droite. mais ce que j'ai, c'est qu'il se déplace rapidement et se déplace ensuite correctement vers la droite.comment exécuter plusieurs animations dans une rangée?

qu'est-ce qui m'a manqué ici?

+0

double possible de [Trigerring autre animation après la première se terminant Animation (objectif Objectif-C)] (http://stackoverflow.com/questions/2710939/trigerring-other-animation-after-first-ending-animation- objetive-c) – kennytm

+0

merci l'homme !!!!! – shawhu

Répondre

1

Vous devez démarrer la deuxième animation à partir de la méthode de délégué animationDidStop.

 
-(ibaction)sometouched:(id)sender 
{ 
    [UIView beginAnimations:@"first one" context:nil]; 
    [UIView setAnimationDuration:1.0]; 
    [myview setFrame:CGRectMake(0,y,width.height.); 
    [UIView setAnimationDelegate:self]; 
    [UIView commitAnimations]; 
} 

- (void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag { 
    [UIView beginAnimations:@"second one" context:nil]; 
    [UIView setAnimationDuration:1.0]; 
    [myview setFrame:CGRectMake(x,0,width.height.); 
    [UIView setAnimationDelegate:nil]; 
    [UIView commitAnimations]; 
} 
Questions connexes