let exifOrientation: CGImagePropertyOrientation switch curDeviceOrientation { case UIDeviceOrientation.portraitUpsideDown : exifOrientation = .left case UIDeviceOrientation.landscapeLeft: exifOrientation = .upMirrored case UIDeviceOrientation.landscapeRight: exifOrientation = .down case UIDeviceOrientation.portrait: exifOrientation = .up default: exifOrientation
. @"4.0" //获取设备方向 @property(nonatomic,readonly) UIDeviceOrientation orientation; //获取设备UUID对象 float batteryLevel NS_AVAILABLE_IOS(3_0); 设备方向的枚举如下: typedef NS_ENUM(NSInteger, UIDeviceOrientation
67 68 let orientation = UIDevice.current().orientation 69 if orientation == UIDeviceOrientation.portraitUpsideDown ciImage.applying(CGAffineTransform(rotationAngle: CGFloat(M_PI / 2.0))) 71 } 72 else if orientation == UIDeviceOrientation.portrait ciImage.applying(CGAffineTransform(rotationAngle: CGFloat(M_PI / -2.0))) 74 } 75 else if (orientation == UIDeviceOrientation.landscapeRight
部分界面横屏 七、默认横屏无效的问题 八、关于旋转后的适配问题 九、APP启动即全屏 一、最让人纠结的三种枚举 刚开始接触屏幕旋转这块知识的时候,最让人抓狂的也许就是三种相关的枚举类型了,它们就是UIDeviceOrientation 设备方向:UIDeviceOrientation UIDeviceOrientation是硬件设备(iPhone、iPad等)本身的当前旋转方向,设备方向有7种(包括一种未知的情况),判断设备的方向是以 typedef NS_ENUM(NSInteger, UIDeviceOrientation) { UIDeviceOrientationUnknown, UIDeviceOrientationPortrait UIInterfaceOrientationLandscapeRight = UIDeviceOrientationLandscapeLeft } __TVOS_PROHIBITED; 区别与UIDeviceOrientation UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight), } __TVOS_PROHIBITED; 我们知道UIDeviceOrientation
orientation]; [self takeImageCompletion:tempImage buffer:nil error:error]; } } // 这个方法可以放在UIDeviceOrientation 的Category中统一定义 - (UIImageOrientation)getUIImageOrientationFromDevice { UIDeviceOrientation orientation
基础概念 UIDeviceOrientation UIDeviceOrientation,表示设备朝向,可以通过[UIDevice currentDevice] orientation]获取,取值有: typedef NS_ENUM(NSInteger, UIDeviceOrientation) { UIDeviceOrientationUnknown, // 未知, // 屏幕朝下 } UIInterfaceOrientation UIInterfaceOrientation,表示页面内容朝向,注意UIInterfaceOrientation和UIDeviceOrientation
返回 UIDeviceOrientationUnknown 解决:延迟回调 complete 后获取 Codes: NSString *MODeviceOrientationDescription(UIDeviceOrientation * _Nullable error); void MOGeometryUpdate(UIViewController *viewController, UIDeviceOrientation
具体代码: -(void)layoutSubviews{ [super layoutSubviews]; UIDeviceOrientation interfaceOrientation=[[ -(void)layoutSubviews{ [super layoutSubviews]; UIDeviceOrientation interfaceOrientation=[[UIApplication
self.app.keyboards // 等等 二、XCUIDevice XCUIDevice可以模拟iOS设备的物理按钮、设备方向和Siri交互的代理 let device = XCUIDevice.shared // UIDeviceOrientation 键在右侧 // landscapeRight: 设备水平方向,Home键在左侧 // faceUp: 面向设备平面,面朝上 // faceDown: 面向设备平面,面朝下 let orientation: UIDeviceOrientation
. @"4.0" @property(nonatomic,readonly) UIDeviceOrientation orientation __TVOS_PROHIBITED; // return
- (void)viewWillLayoutSubviews{ [self _shouldRotateToOrientation:(UIDeviceOrientation)[UIApplication sharedApplication].statusBarOrientation]; } - (void)_shouldRotateToOrientation:(UIDeviceOrientation
UIDeviceProximityStateDidChangeNotification NS_AVAILABLE_IOS(3_0); 其中,设备方向的枚举选项有以下几种: typedef NS_ENUM(NSInteger, UIDeviceOrientation
property(nonatomic,readonly) CGRect bounds; ——————————————————————————– //考虑转屏的影响,按照实际屏幕方向(UIDeviceOrientation
--------------------------------------------------------------------------- //考虑转屏的影响,按照实际屏幕方向(UIDeviceOrientation
property(nonatomic,readonly) CGRect bounds; ——————————————————————————– //考虑转屏的影响,按照实际屏幕方向(UIDeviceOrientation
-------------------------------------------------------------------------------- //考虑转屏的影响,按照实际屏幕方向(UIDeviceOrientation