您好,欢迎来到伴沃教育。
搜索
您的当前位置:首页自动转屏

自动转屏

来源:伴沃教育

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

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

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

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

Copyright © 2019- bangwoyixia.com 版权所有 湘ICP备2023022004号-2

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务