2010-11-12 5 views
0

J'ai créé une animation sur mon projet qui permute entre 2 UIWebView. Quand je développais sur iOS 3.2 tout allait bien avec l'animation. Mais quand je suis passé à iOS 4.2 tout à coup tout va mal: Quel est le problème avec ces animations sur iOS 4.2?

//LeftView Animation 

    [UIView beginAnimations:@"leftPortrait" context:nil]; 
    [UIView setAnimationDelegate:self]; 
    [UIView setAnimationDuration:1.0f]; 
    [UIView setAnimationBeginsFromCurrentState:YES]; 
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:leftView cache:YES]; 
    [leftWebView setFrame:CGRectMake(0, 0, 384, 916)]; 
    [UIView commitAnimations]; 

    //RightView Animation 
    [UIView beginAnimations:@"rightPortrait" context:nil]; 
    [UIView setAnimationDelegate:self]; 
    [UIView setAnimationDuration:1.0f]; 
    [UIView setAnimationBeginsFromCurrentState:YES]; 
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:rightView cache:YES]; 
    [rightWebView setFrame:CGRectMake(0, 0, 384, 916)]; 
    [UIView commitAnimations]; 

Merci!

Répondre

1

Essayez d'utiliser des animations basées sur des blocs.

Ils sont plus propres, plus souples et sont également la manière actuelle d'Apple de faire les choses. Passer de [UIView beginAnimations: context:] à des animations basées sur des blocs a également récemment corrigé un problème d'animation dans mon code.

Dans votre cas, une simple version d'animation basée sur des blocs serait [UIView animateWithDuration:1.0f animations:^{[leftWebView setFrame:CGRectMake(0, 0, 384, 916)];}. Vous voudrez probablement utiliser -[UIView animateWithDuration:delay:options:animations:animations:completion:] pour définir vos autres options et le code qui doit être exécuté lorsque les animations sont terminées.

Questions connexes