I ended up using viewDidLayoutSubviews
. Then I used setFrame
for each UI element to programmatically set the location of each element.
For others with this issue here is what your code might look like:
-(void)viewDidLayoutSubviews
{
[super viewDidLayoutSubviews];
CGSize size = [UIScreen mainScreen].bounds.size;
UIApplication *app = [UIApplication sharedApplication];
UIInterfaceOrientation orientation = [app statusBarOrientation];
if (UIInterfaceOrientationIsLandscape(orientation)) size = CGSizeMake(size.height, size.width);
if (!app.statusBarHidden) size.height -= MIN(app.statusBarFrame.size.width, app.statusBarFrame.size.height);
if (UIInterfaceOrientationIsLandscape(orientation))
{
// code to handle UI elements in landscape view here
// x and y can be anything from 0 to size.height for y and size.width for x
// example:
CGRect logOutFrame = [self logOutButton].frame;
logOutFrame.origin.y = 10;
logOutFrame.origin.x = 20;
logOutFrame.size.width = 80;
logOutFrame.size.height = 30;
[[self logOutButton] setFrame:logOutFrame];
}
}