繁体   English   中英

检查iOS中的应用方向(不是设备方向)

[英]Check the app orientation in iOS (not the device orientation)

到目前为止,我以前一直使用以下代码检查我的设备是否处于纵向或横向模式:

if (UIDeviceOrientationIsPortrait(UIDevice.current.orientation)){
           //portrait

}else {
          //landscape        
}

但是我发现此变量检查设备在3D空间中的实际位置。 因此,如果我的iPad或iPhone处于纵向模式,并且将其放在平行于地面的桌子上,则方向不会被视为纵向。 是否可以检查某个变量或类似内容以了解应用程序的方向,而不是物理方向?

使用UIApplication.shared.statusBarOrientation :应用程序状态栏的当前方向。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM