iphone自转动画 [英] iphone autorotation animation

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

问题描述

是否有可能关闭动画的自转?我希望它旋转,但我只是不想发生的动画(如即时开关)。

Is it possible to turn off the animation for the autorotation? I want it to rotate, but I just dont want the animation to occur (like an instant switch).

推荐答案

只需添加以下code覆盖标准的旋转动画:

Just add the following code to overwrite the standard rotation animation:

- (void)viewDidLoad
{
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didRotate:)   name:UIDeviceOrientationDidChangeNotification object:nil];
}

- (void)didRotate:(NSNotification *)notification {
    orientation = [[UIDevice currentDevice] orientation];
    if(orientation == UIDeviceOrientationUnknown || orientation == UIDeviceOrientationFaceDown || orientation == UIDeviceOrientationFaceUp){
        orientation = UIDeviceOrientationPortrait;
    }
    [[UIApplication sharedApplication] setStatusBarOrientation:orientation animated:NO];
    [self positionScreenElements];
}

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

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