iOS 4.2 上的这个动画有什么问题吗?

发布于 2024-10-02 05:45:10 字数 999 浏览 8 评论 0原文

我在我的项目上创建了在 2 个 UIWebView 之间交换的动画。 当我在 iOS 3.2 上进行开发时,动画一切都很好。 但当我转向 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];

谢谢!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

长途伴 2024-10-09 05:45:10

尝试使用基于块的动画。

它们更干净、更流畅,也是当前苹果的做事方式。从 [UIView beginAnimations:context:] 切换到基于块的动画最近还修复了我的代码中的动画问题。

在您的情况下,一个简单的基于块的动画版本将是 [UIView animateWithDuration:1.0fanimations:^{[leftWebView setFrame:CGRectMake(0, 0, 384, 916)];}
您可能需要使用 -[UIView animateWithDuration:delay:options:animations:animations:completion:] 来设置其他选项以及动画完成时应执行的代码。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文