How to get device orientation via UIView reference?

ios, uiinterfaceorientation, uiview

Solution

You can also get the device orientation from UIApplication, have you tried using

UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];

Problem

I need to get device orientation from a ViewController. I cannot base on: ``` [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation]; ``` because it sometimes returns orientation unknown (for example when the device lays on the table). I just need to know in what orientation is my current UIView displayed (is it landscape left or landscape right). I don't need to have this value updated when orientation changes, I just want to know it, when I ask for it. Just some reference view.orientation ;). Is there something that would help me? I've read UIView documentation, found some reference to UIWindow, but nothing that could help me.

Original source