热门搜索 :
考研考公
您的当前位置:首页正文

自动转屏

来源:东饰资讯网

设备方向发生变化时,应用会收到信的方向信息,并根据相关设置决定是否感觉新的设备方向调整界面方向。

如果需要修改默认支持方向,则必须在相应的UIViewController中覆盖supportInterfaceOrientations方法,该方法的默认实现类似于一下代码:

- (UIInterfaceOrientationMask)supportedInterfaceOrientations
{
    if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) {   //判断当前设备类型
        return UIInterfaceOrientationMaskAll;
    } else {
        return UIInterfaceOrientationMaskAllButUpsideDown;
    }
}

如果需要在界面方向发生变化时之行某些操作,则可以在UIViewController中覆盖willAnimateRotationToInterfaceOrientation: duration: 方法。在界面方向发生改变后,UIViewController会收到willAnimateRotationToInterfaceOrientation: duration: 消息,消息的第一个参数是新的界面方向。

Top