You can get the orientation of device by “UIDevice.current.orientation” , but it returns .unKnown when the app has just be launched.
In these case, use UI Interface Orientation instead.
iOS12 or earlier
UIApplication.shared.statusBarOrientation
iOS 13 or later
self.view.window?.windowScene!.interfaceOrientation
*However, because it is the orientation of the interface on the screen
If you check the UIInterfaceOrientation when the view does not appear, it will be nil.
Make sure to check between viewDidAppear ~ viewWillDisAppear.
Also, the orientation cannot be recognized when it is laid down (.faceUp, .faceDown).
**
We send information related to machine learning and iOS.
contact:
rockyshikoku@gmail.com