>

C剖断设备当前的来头

- 编辑:www.bifa688.com -

C剖断设备当前的来头

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;  
    }

本文由bifa688.com发布,转载请注明来源:C剖断设备当前的来头