Pergunta

I created animation on my project that swaps between 2 UIWebView. When I was developing on iOS 3.2 everything was fine with the animation. But when I moved to iOS 4.2 suddenly everything goes wrong:

    //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];

Thanks!

Foi útil?

Solução

Try using block-based animations.

They are cleaner, smoother and are also the current Apple Way to do things. Switching from [UIView beginAnimations:context:] to block-based animations also fixed an animation problem in my code recently.

In your case, a simple block-based animations version would be [UIView animateWithDuration:1.0f animations:^{[leftWebView setFrame:CGRectMake(0, 0, 384, 916)];}. You'll probably want to use -[UIView animateWithDuration:delay:options:animations:animations:completion:] for setting your other options and the code that should be executed when the animations are finished.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top