I have app that can start in portrait or landscape mode. Controls on main screen look differently depending in which mode application is.
Here is the problem - if i start application in landscape mode, controls arent where they should be, they retain their positions like app is portrait mode. I tried to test this a little bit, and here is what I found -
in viewDidLoad and ViewWillappear i get info that app is in portrait mode, although app is landscape mode. In view did appear it is set to correct value - landscape mode. Problem is i want these components to be set on their proper positions, before view appears (if don't i can clearly see them reposition on screen).
What is proper way to handle this?
EDIT: in viewDidLoad and ViewWillAppear, i call this:
orientation = [self getOrientation];
if (orientation == OrientationsLandscape) {
NSLog(@"Landscape");
}
else {
NSLog(@"Portrait");
}
here is implementation of [getOrientation]
- (int) getOrientation {
int currentOrientation = [UIApplication sharedApplication].statusBarOrientation;
if (UIInterfaceOrientationIsPortrait(currentOrientation)) return OrientationsPortrait;
else return OrientationsLandscape;
}
and enumeration def:
typedef enum {
OrientationsLandscape = 0,
OrientationsPortrait
} Orientations;
Now if device is landscape mode and i try to install my app, i will get 2 times printed "Portrait", instead "Landscape"