If your interest is your interface orientation (i.e. landscape or device portrait orientation), you should NOT use UIDevice: orientation (or UIDeviceOrientation * constants, if you want), but rather use UIApplication: statusBarOrientation, which uses UIInterfaceOrientation * constants.
I use the following code to check landscape modus:
static inline bool isOrientationIsLandscape() { return UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation]); }
And for portrait mode:
static inline bool isOrientationIsPortrait() { return UIInterfaceOrientationIsPortrait([[UIApplication sharedApplication] statusBarOrientation]); }
It cost me a whole morning to understand, because there is no UIDeviceOrientationFace [Up | Down], only on a real device. Thus, my application worked on the simulator all the time, but on the device itself from time to time I had some undefined behavior during testing.
Now it works on the device itself, as on a simulator.
NTN
source share