开发者

What's wrong with this animations on iOS 4.2?

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 setAnima开发者_运维问答tionBeginsFromCurrentState: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!


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜