【问题标题】:Can I "curl down" a page on popViewControllerAnimated?我可以“卷曲”popViewController Animated 上的页面吗?
【发布时间】:2010-09-13 11:16:47
【问题描述】:

我可以用这段代码“卷起”一个视图控制器:

[UIView beginAnimations:@"animation" context:nil];
[self.navigationController pushViewController:page animated:NO];
[UIView setAnimationDuration:1];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.navigationController.view cache:NO]; 
[UIView commitAnimations];

但我不能像这样卷曲最后一页:

[UIView beginAnimations:@"animation" context:nil];
[self.navigationController popViewControllerAnimated:NO];
[UIView setAnimationDuration:1];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.navigationController.view cache:NO]; 
[UIView commitAnimations];

知道为什么不呢?我只是真的想“反转”动画(好像贴纸已被剥离以显示“推送”视图控制器并在他们单击按钮时重新贴上)。

谢谢

【问题讨论】:

    标签: uiview pushviewcontroller popviewcontroller uianimation


    【解决方案1】:

    好吧,我的旧答案完全错误...... 问题是您在设置转换视图之前弹出视图控制器。如果你把代码改成这样:

    [UIView beginAnimations:@"animation" context:nil];
    [UIView setAnimationDuration:1];
    [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.navigationController.view cache:NO]; 
    [self.navigationController popViewControllerAnimated:NO];
    [UIView commitAnimations];
    

    效果很好

    【讨论】:

    • 盲目复制粘贴并在第一时间工作。值得投票和推荐的解决方案。
    【解决方案2】:

    使用 OpenGL 或许多复杂的 CoreAnimation 过程,我相信你可以,但是,这样做会很麻烦。可能对您有所帮助的东西:A simple book turning application written entirely with CoreAnimation

    【讨论】:

    • 啊...那么它不像我的(猜测的)代码那么简单吗?感谢您的链接。 :)
    • 奇怪的是,上面的代码对我来说工作得很好,但我不知道这是否是你想要的过渡..
    • 它对我不起作用... :/ 如果我在设备上而不是模拟器上尝试... :/ 我会回复你的。
    • hmm ..我只是有一个虚拟 uiview,然后在按下它的背景时在虚拟 uiview 上使用上述动画......所以我不知道这样做是否有问题导航控制器,或者您的模拟器/设备有问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-11-10
    • 2011-04-24
    • 2018-12-24
    • 1970-01-01
    • 1970-01-01
    • 2012-12-15
    • 1970-01-01
    相关资源
    最近更新 更多