ios入门:自适应屏幕旋转

来源:互联网 发布:vb key value 编辑:程序博客网 时间:2024/06/05 14:19

选择视图支持的方向:

1、应用级(全局)设置:

      项目 general配置->Deployment info->Device Orientation.

      有4种方向可选:portrait                 竖直

uoside down         倒立

landscape right     右横屏

landscape left       左横屏

    iphone 默认不支持uoside down,ipad 默认全支持


    以上的设置都可以在Info.plist文件中进行编辑


2、视图级设置   

     视图级支持的方向只能是应用级支持方向的子集

     在view controller的实现文件里要实现UIViewController中的一个方法来指定当前视图支持的方向

     

-(NSUInteger)supportedInterfaceOrientations {

    return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft);

}


实现了可支持竖直和左横屏。

原创粉丝点击