禁用方向更改旋转动画 [英] Disable orientation change rotation animation

查看:32
本文介绍了禁用方向更改旋转动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要禁用在方向改变时播放的动画.这可能吗?如果没有,是否可以加快速度?

I need to disable the animation that plays when the orientation changes. Is this possible? If not, is it possible to speed it up?

澄清一下,我不想停止方向改变,只想停止动画.我想要一个即时的方向改变.

Just to clarify, i don't want to stop the orientation change, just the animation. I want an instant orientation change.

推荐答案

如果我没记错的话(这总是我必须玩一会儿才能正确的事情)willRotateToInterfaceOrientation:duration:willAnimateRotationToInterfaceOrientation:duration: 都在动画块内,而 didRotateFromInterfaceOrientation: 在动画块之后运行.我相信您需要在 willRotate 中布置您的视图,以便它们出现在旋转后出现的位置如果它们没有旋转(如果这是有道理的).通过这种方式,动画会将它们从原始(正确)布局设置为与设备旋转方向相反的新(旋转)布局,从而创建没有动画的外观.旋转完成后,您可以在 didRotate 中布置您的视图,无需动画,给人的印象是它们立即旋转.

If I remember correctly (this is always the sort of thing I have to play around with for a moment to get right) willRotateToInterfaceOrientation:duration: and willAnimateRotationToInterfaceOrientation:duration: are both inside the animation block, while didRotateFromInterfaceOrientation: runs after the animation block. I believe you would need to lay out your views in willRotate so they appear in the position in which they would appear after the rotation had they not rotated (if that makes sense). This way the animation will animate them from their original (correct) layout to the new (rotated) layout in the opposite direction that the device rotates, creating the appearance of no animation. Once the rotation is complete, you can lay out your views, without animation, in didRotate, giving the impression that they rotate instantly.

像泥一样清澈,不是吗?

Clear as mud, no?

这篇关于禁用方向更改旋转动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆