I'm trying to make a camera overlay view on top of the camera accomodate according to the screen orientation. Since even if you lock your screen orientation on the settings, the camera still rotates its UI (the flash and camera buttons that are on the live preview), if I don't move the elements I have on the overlay view, it stays on top of those.
I already accomplished this by registering to the UIDeviceOrientationDidChangeNotification
notification, and then reading the value on [UIDevice currentDevice].orientation
and setting the transform value of my camera overlay view.
The problem with this is the UIDeviceOrientationDidChangeNotification
notification doesn't fire when the user locks the interface on their iPhone (but the camera keeps rotating!).
I've tried a number of alternatives, like registering to the PLCameraDeviceOrientationChangedNotification
notification that I found being fired when registering myself as an observer for every notification, but it doesn't contain the orientation on the userInfo dictionary.
I also tried setting up a NSTimer
to fire every 0.5s and check the [UIDevice currentDevice].orientation
, but it always reports UIDeviceOrientationPortrait when it's locked, regardless of the actual device orientation.
Is there any way I can find out the orientation the camera is in, and ideally also be notified when it changes even with the interface orientation locked by the user?
Thanks.