方向更改时更改或禁用iPhone旋转动画 [英] Change or disable the iPhone rotating animation when orientation changes

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

问题描述

当屏幕方向从横向更改为纵向时,如何更改或禁用旋转动画,反之亦然?

How do I change or disable the rotating animation when screen orientation changes from landscape to portrait, or vice versa?

推荐答案

如果您不希望视图控制器旋转,只需覆盖shouldAutoRotateToInterface视图控制器方法,以便为您不想支持的任何方向返回false ... 这是一个参考

If you dont want your view controllers to rotate just override the shouldAutoRotateToInterface view controller method to return false for whichever orientation you dont want to support...Here is a reference.

如果您只想以其他方式处理旋转,可以在上述方法中返回false并注册UIDeviceOrientationDidChangeNotification,如此

In the case that u just want to handle rotation some other way, you can return false in the above methods and register for UIDeviceOrientationDidChangeNotification like so

    NSNotificationCenter* nc = [NSNotificationCenter defaultCenter];
[nc addObserver:self
       selector:@selector(handleOrientationDidChange:)
           name:UIDeviceOrientationDidChangeNotification
         object:nil];

现在,当你收到通知时,你可以随心所欲地做任何事......

Now when u get the notifications u can do whatever you want with it...

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

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