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; }</pre>
本文由用戶 y35w 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!