I am using the following code to keep the buttons, labels, and imageview to certain parts of the screen when rotated:
This is working, but I ran into an issue. Each tab is a navigation controller and I set the Navigation Bar to hidden. Some buttons push a simple view controller that is located in the MainWindow.xib
Some buttons push a TableView Controller that has its own xib
The table view codes "Unhide" the navigation bar when loaded so they can be redirected back to the root view controller. The issue I have is this:
When a button just pushes to a view controller and then comes back, all buttons are in the right spot. However, after coming back from a tableview, the imageview is still in the same place, but the labels and buttons have been shifted down by the height of the navigationbar. Any thoughts on how to fix this?
MORE INFO:
I turned off autoresize subviews for the views that were being adjusted down, and it keeps buttons in place, but makes rotations look less smooth.
Code:
- (void) viewWillAppear:(BOOL)animated
{
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight)
{
viewofimage.frame = CGRectMake(130, 45, 220, 115);
news.frame = CGRectMake(141, 161, 70, 70);
bulletin.frame = CGRectMake(8, 161, 70, 70);
facebook.frame = CGRectMake(402, 161, 70, 70);
blog.frame = CGRectMake(269, 161, 70, 70);
invitation.frame = CGRectMake(22, 227, 43, 21);
sharing.frame = CGRectMake(159, 227, 38, 21);
contacting.frame = CGRectMake(409, 227, 58, 21);
blogging.frame = CGRectMake(276, 227, 56, 21);
}
else {
viewofimage.frame = CGRectMake(20, 64, 280, 206);
bulletin.frame = CGRectMake(8, 285, 70, 70);
news.frame = CGRectMake(86, 285, 70, 70);
facebook.frame = CGRectMake(242, 285, 70, 70);
invitation.frame = CGRectMake(22, 358, 43, 21);
sharing.frame = CGRectMake(102, 358, 38, 21);
contacting.frame = CGRectMake(249, 358, 58, 21);
blogging.frame = CGRectMake(172, 358, 56, 21);
blog.frame = CGRectMake(164, 285, 70, 70);
} [self.navigationController setNavigationBarHidden:YES animated:animated];
[super viewWillAppear:animated];
}
...
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight)
{
viewofimage.frame = CGRectMake(130, 45, 220, 115);
news.frame = CGRectMake(141, 161, 70, 70);
bulletin.frame = CGRectMake(8, 161, 70, 70);
facebook.frame = CGRectMake(402, 161, 70, 70);
blog.frame = CGRectMake(269, 161, 70, 70);
invitation.frame = CGRectMake(22, 227, 43, 21);
sharing.frame = CGRectMake(159, 227, 38, 21);
contacting.frame = CGRectMake(409, 227, 58, 21);
blogging.frame = CGRectMake(276, 227, 56, 21);
}
else {
viewofimage.frame = CGRectMake(20, 64, 280, 206);
bulletin.frame = CGRectMake(8, 285, 70, 70);
news.frame = CGRectMake(86, 285, 70, 70);
facebook.frame = CGRectMake(242, 285, 70, 70);
invitation.frame = CGRectMake(22, 358, 43, 21);
sharing.frame = CGRectMake(102, 358, 38, 21);
contacting.frame = CGRectMake(249, 358, 58, 21);
blogging.frame = CGRectMake(172, 358, 56, 21);
blog.frame = CGRectMake(164, 285, 70, 70);
}
return YES;
}
This is working, but I ran into an issue. Each tab is a navigation controller and I set the Navigation Bar to hidden. Some buttons push a simple view controller that is located in the MainWindow.xib
Code:
-(IBAction) social {
[self.navigationController pushViewController:social animated:YES]; }
Code:
-(IBAction) news {
NewsViewController *dvController8 = [[NewsViewController alloc] initWithNibName:@"NewsViewController" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:dvController8 animated:YES];
[dvController8 release];
}
When a button just pushes to a view controller and then comes back, all buttons are in the right spot. However, after coming back from a tableview, the imageview is still in the same place, but the labels and buttons have been shifted down by the height of the navigationbar. Any thoughts on how to fix this?
MORE INFO:
I turned off autoresize subviews for the views that were being adjusted down, and it keeps buttons in place, but makes rotations look less smooth.
Last edited: