Try this out in your .m file:
- (void)updateLayoutForNewOrientation:(UIInterfaceOrientation)orientation
{
if (self.interfaceOrientation == UIInterfaceOrientationPortrait || self.interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
{
// Portrait
[object setFrame:CGRectMake(...)];
// Do the same for the rest of your objects
}
else
{
// Landscape
[object setFrame:CGRectMake(...)];
// Do the same for the rest of your objects
}
}
In the function, you have defined the position of each object in your view, for both Portrait and Landscape.
Then you call that function in viewWillAppear
to initially make it work; the view determines which orientation to use at start:
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self updateLayoutForNewOrientation:self.interfaceOrientation];
}
Also, for when you rotate:
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration
{
[self updateLayoutForNewOrientation:self.interfaceOrientation];
}
This is the approach I take if I need a more customized look in regard to orientation. Hope that'll work for you.
EDIT:
If you use two UIViews, one for portrait and another for landscape, in one UIViewController, you would change that first part of the code to look like this:
- (void)updateLayoutForNewOrientation:(UIInterfaceOrientation)orientation
{
if (self.interfaceOrientation == UIInterfaceOrientationPortrait || self.interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
{
// Portrait
portraitView.hidden = NO;
landscapeView.hidden = YES;
}
else
{
// Landscape
portraitView.hidden = YES;
landscapeView.hidden = NO;
}
}
There are pros and cons between this edited sample and the original. In the original, you have to code for every object, in this edited sample this code is all you need, however, you need to essentially allocate objects twice, one for a portrait view and another for a landscape view.