iPhone判断设备当前的方向

2015-07-09 0 586
iPhone判断设备当前的方向
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; 
    }

遇见资源网 objective-c iPhone判断设备当前的方向 http://www.ox520.com/17973.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务