ekurutepe / MPNotificationView

An in-app notification view that mimics the iOS 6 notification views which appear above the status bar
MIT License
346 stars 55 forks source link

iPad orientation not correct in simulator #14

Closed zetachang closed 11 years ago

zetachang commented 11 years ago

Below is what I got in the simulator, the correct orientation cannot be detected. Screen Shot 2013-02-18 at 4 04 05

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 return UIDeviceOrientationUnknown.

Apple's document state that

You get the current orientation using the orientation property or receive change notifications by registering for the UIDeviceOrientationDidChangeNotification notification. Before using either of these techniques to get orientation data, you must enable data delivery using the beginGeneratingDeviceOrientationNotifications method

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.

cswelin commented 11 years ago

I've noticed this happen a few times on a device as well.

zetachang commented 11 years ago

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.

ekurutepe commented 11 years ago

Fixed by #18