This is how I do it. I made a function called configureViewForOrientation:
that takes as a parameter the orientation that you want to set up the interface for.
-(void)configureViewForOrientation:(UIInterfaceOrientation)orientation
{
if (UIInterfaceOrientationIsPortrait(orientation))
{
//set up portrait interface
}
else
{
//set up landscape interface
}
}
You can call this method from your viewDidLoad
(or wherever you initially set up your interface) and feed it the current orientation using [UIApplication sharedApplication].statusBarOrientation
:
-(void)viewDidLoad
{
[super viewDidLoad];
[self configureViewForOrientation:[UIApplication sharedApplication].statusBarOrientation];
}
You can also call it when your device is rotated:
-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
[super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
[self configureViewForOrientation:toInterfaceOrientation];
}
There are a couple caveats (such as whether you're checking device orientation immediately upon app launch) but this should work for the majority of the time.