I run a simple function that is called in several areas to help deal with the layout in the iPad application during orientation changes. It looks like this:
- (void) getWidthAndHeightForOrientation:(UIInterfaceOrientation)orientation { NSLog(@"New Orientation: %d",orientation); end
And I call it in different places:
[self getWidthAndHeightForOrientation: [[UIDevice currentDevice] orientation]];
A function usually has some simple code that executes if the orientation is portrait or landscape. Unfortunately, it did not work as expected, when the application starts in what will be at position 1. As a result, I get 0. Later, if the function is called in the same way, but the device never rotates, I return 5. What it means? Why is it throwing these values?
In short, why does the [[UIDevice currentDevice] orientation] ever throw 0 or 5 instead of any value between 1 and 4?
UPDATE:
As I continued to find errors in my code due to how orientation was handled, I wrote the final post on how to handle UIDevice or UIInterface orientations: http://www.donttrustthisguy.com/orientating-yourself-in-ios
source share