I need to get the interface orientation in the viewWillAppear method of my UIViewController. What I did is:
if (self.interfaceOrientation == UIInterfaceOrientationPortrait)
NSLog(@"Portrait");
else
NSLog(@"Landscape");
When in landscape, I'm always getting Portrait in the viewWillAppear and Landscape in the viewDidAppear. Why?
So, I tried using [[UIApplication sharedApplication] statusBarOrientation], but the same happens. I also tried another solution posted here in Stack Overflow:
UIDevice* device = [UIDevice currentDevice];
[device beginGeneratingDeviceOrientationNotifications];
UIDeviceOrientation currentOrientation = device.orientation;
[device endGeneratingDeviceOrientationNotifications];
This seems to correctly return the orientation, but now I'm left with the problem of mapping UIDeviceOrientation to UIInterfaceOrientation, which is not possible as far as I know (face up and face down cannot be mapped).
Any solution to this issue?