iPhone判断设备当前的方向

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

UIDevice *device = [UIDevice currentDevice];
switch (device.orientation;) { 
        case UIDeviceOrientationFaceUp: 
            NSLog(@"螢幕朝上平躺"); 
            break; 
              
        case UIDeviceOrientationFaceDown: 
            NSLog(@"螢幕朝下平躺"); 
            break; 
              
        //系統無法判斷目前Device的方向,有可能是斜置  
        case UIDeviceOrientationUnknown: 
            NSLog(@"未知方向"); 
            break; 
              
        case UIDeviceOrientationLandscapeLeft: 
            NSLog(@"螢幕向左橫置");
            //imgView.transform = CGAffineTransformMakeRotation((CGFloat)(-90 * M_PI / 180.0));
            break; 
              
        case UIDeviceOrientationLandscapeRight: 
            NSLog(@"螢幕向右橫置"); 
            //imgView.transform = CGAffineTransformMakeRotation((CGFloat)(90 * M_PI / 180.0));
            break; 
              
        case UIDeviceOrientationPortrait: 
            NSLog(@"螢幕直立"); 
            break; 
              
        case UIDeviceOrientationPortraitUpsideDown: 
            NSLog(@"螢幕直立,上下顛倒"); 
            break; 
              
        default: 
            NSLog(@"無法辨識"); 
            break; 
    }