Unverse通配版本总结

本项目需求是手机端支持竖屏,个别页面支持横屏,pad端支持横竖屏。


Unverse通配版本总结_第1张图片

一:对不同端做横竖屏方向的权限限制:

第一种方法:咋infoplist中加入以下代码:



Unverse通配版本总结_第2张图片



第二种方法:

代码实现:在APPdelegate中 写入方法

- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {

   if (IS_IPHONE) { 

return UIInterfaceOrientationMaskPortrait;

}else

       return UIInterfaceOrientationMaskAll;

}

刚开始用的是第一种方法,但是在处理pad端保利视频播放器页面全屏播放的时候,发现有冲突,这个坑原因还没想出来,后期补上。个人建议用第二种方法,后期牵扯到横竖屏的一些问题,比较容易拓展。

二:前期没有做过pad端的项目,所以在项目前期,对项目预测以及时间的把握上不是很精准

三:对于横竖屏判断方法:

第一种方法:

if ([[UIDevice currentDevice] orientation] == UIDeviceOrientationPortrait || [[UIDevice currentDevice] orientation] == UIDeviceOrientationPortraitUpsideDown ) {

        NSLog(@"竖屏");

 } else if ([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeLeft || [[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeRight){

 NSLog(@"横屏");

}

第二种 方法:

UIApplication* app = [UIApplication sharedApplication];

    // 判断设备方向状态,做响应的操作

    if(app.statusBarOrientation == UIInterfaceOrientationPortrait || app.statusBarOrientation == UIInterfaceOrientationPortraitUpsideDown){

        NSLog(@"竖屏");

    }else if(app.statusBarOrientation == UIInterfaceOrientationLandscapeLeft || app.statusBarOrientation == UIInterfaceOrientationLandscapeRight){

        NSLog(@"横屏");

    }

判断横竖屏的方法有很多,我先简单 说一下我入的坑,第一种方法是判断的设备的物理状态,一共是6个状态,竖屏(2)横屏(2)水平(2),在执行横竖屏转换的时候横竖屏状态下页面布局是没有问题的,水平状态下,页面布局就出现问题了,为了避免页面竖屏,设备水平放置,页面横屏,设备水平放置,的尴尬,个人建议用第二种方法,通过查看当前电池条的状态来确定。

四:个别页面单独设置横竖屏

方法:在APPdelegate总定义一个allowRotate,

- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {

    if (_allowRotate == 1) {

          return UIInterfaceOrientationMaskAll;

    }

    else{

          return UIInterfaceOrientationMaskPortrait;

    }

五:上架过程补充。

你可能感兴趣的:(Unverse通配版本总结)