Closed zetachang closed 11 years ago
I've noticed this happen a few times on a device as well.
I've discovered the issue is mainly caused by when the device is not in either a portrait or landscape orientation. That is, UIDeviceOrientationUnknown
, UIDeviceOrientationFaceUp
and UIDeviceOrientationFaceUp
.
Fixed by #18
Below is what I got in the simulator, the correct orientation cannot be detected.
To reproduce it, make the iPad simulator in landscape orientation before opening the test app. After launching it, the presented notification view will show aside rather than appearing on the top.
I checked the value of
[[UIDevice currentDevice] orientation]
in debugger, it seems that if there is no orientation changes made since the app has launched, it will always returnUIDeviceOrientationUnknown
.Apple's document state that
I am not sure where to place the method and it seems weird that it works on real device without calling the
beginGeneratingDeviceOrientationNotifications
method.Another solution may be switching to use
[UIApplication sharedApplication].statusBarOrientation
. I've tested it on the simulator and it returned the correct interface orientation.