Get device current orientation (App Extension)

后端 未结 10 1469
执笔经年
执笔经年 2020-12-09 10:02

How to get device current orientation in an App Extension, I have tried below two methods but no success.

  1. It always return UIDeviceOrientationUnknown

    <
10条回答
  •  伪装坚强ぢ
    2020-12-09 10:50

    This code won't give you the exact UIDeviceOrientation but you'll be able to know if it's in portrait or landscape mode

    BOOL isLandScape = !(self.view.frame.size.width == ([[UIScreen mainScreen] bounds].size.width*([[UIScreen mainScreen] bounds].size.width<[[UIScreen mainScreen] bounds].size.height))+([[UIScreen mainScreen] bounds].size.height*([[UIScreen mainScreen] bounds].size.width>[[UIScreen mainScreen] bounds].size.height)));
    

提交回复
热议问题