判断横竖屏的方法

1. 

CGRect aRect = [[UIScreenmainScreen] applicationFrame];

    if (aRect.size.height>768) {

        

        NSLog(@"height ::%f",aRect.size.height);

        NSLog(@"竖屏幕.....");

    

    }else {

        NSLog(@"height ::%f",aRect.size.height);

        NSLog(@"横屏幕.....");

    }

 

2. 有时候 没有用  这个问题我没有深究......

 

UIDeviceOrientation DO = [[UIDevicecurrentDevice]orientation];

    NSLog(@"DO::%i",DO);

    if (UIInterfaceOrientationIsPortrait(DO)) {

           NSLog(@"竖屏幕.....");

    }

    else {

         NSLog(@"横屏幕.....");

    }

 

3.

 UIDeviceOrientation DO = self.interfaceOrientation;

    if (UIInterfaceOrientationIsPortrait(DO)) {

 

        // 竖屏

  

    }else {

        NSLog(@"横屏幕.....");

        // 横屏

    

 

    }

原文地址:https://www.cnblogs.com/zander/p/2673429.html