I am stuck with this problem for a while now and I am hoping that someone can help me with this.
This is what I’ve got:
An iPad App with the following screens:
- Homescreen with 4 buttons (no Tabbar or Navigationbar) which points to several Tabs in a coded Tabbar.
- Screen 1 Tableview
- Screen 2 Tableview
- Screen 3 Tableview
- Screen 4 Sectioned TableView
My Homescreen supports Portrait as well as Landscape rotation. When I choose an option on the homescreen (which opens a new view with a tabbar), the view gets reset to PortraitView and doesn’t support Landscape view anymore.
Ive added this code in all the viewcontrollers .m files:
- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation {
return YES;
}
Even a default tableview gets reset to portraitview and no longer supports landscapeview.
In my firstviewcontroller I have this code which creates the Tabbar when a Button on the homescreen has been pressed.
UITabBarController *tabbarController = [[UITabBarController alloc] init];
CategoriesOverviewController *productView = [[CategoriesOverviewController alloc] initWithNibName:@"CategoriesOverviewController" bundle:nil];
UINavigationController *TabBarItem_1 = [[UINavigationController alloc] initWithRootViewController:productView];
productView.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;
[productView setTitle:@"Producten"];
productView.tabBarItem.image = [UIImage imageNamed:@"products.png"];
ShowcaseViewController *showcaseView = [[ShowcaseViewController alloc] initWithNibName:@"ShowcaseViewController" bundle:nil];
UINavigationController *TabBarItem_2 = [[UINavigationController alloc] initWithRootViewController:showcaseView];
showcaseView.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;
[showcaseView setTitle:@"Showcase"];
showcaseView.tabBarItem.image = [UIImage imageNamed:@"showcase.png"];
EventMainmenuViewController *expoView = [[EventMainmenuViewController alloc] initWithNibName:@"EventMainmenuViewController" bundle:nil];
UINavigationController *TabBarItem_3 = [[UINavigationController alloc] initWithRootViewController:expoView];
expoView.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;
[expoView setTitle:@"Beursagenda"];
expoView.tabBarItem.image = [UIImage imageNamed:@"calendar.png"];
CompanyViewController *companyView = [[CompanyViewController alloc] initWithNibName:@"CompanyViewController" bundle:nil];
UINavigationController *TabBarItem_5 = [[UINavigationController alloc] initWithRootViewController:companyView];
companyView.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;
[companyView setTitle:@"About"];
companyView.tabBarItem.image = [UIImage imageNamed:@"About.png"];
FavoritesViewController *favoritesView = [[FavoritesViewController alloc] initWithNibName:@"FavoritesViewController" bundle:nil];
UINavigationController *TabBarItem_4 = [[UINavigationController alloc] initWithRootViewController:favoritesView];
favoritesView.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;
[favoritesView setTitle:@"Favorieten"];
favoritesView.tabBarItem.image = [UIImage imageNamed:@"favorites.png"];
tabbarController.viewControllers = [NSArray arrayWithObjects: TabBarItem_1, TabBarItem_2, TabBarItem_3, TabBarItem_4, TabBarItem_5, nil];
[self presentModalViewController:tabbarController animated:YES];
tabbarController.selectedIndex = 0;
(if there is another way of doing this, please say so!)
Whats missing here!! Do I have to send some extra information with the viewcontroller?
Plz help me!! I would appreciate it very much!!
With Kind Regards,
Douwe
In order for the
UITabBarControllerto support landscape orientation, each of its view controllers needs to support it as well.In this case, you would need to subclass
UITabBarControllerhave itsshouldAutorotateToInterfaceOrientationmethod returnYES, and then have each of its managed view controllers returnYESfor that orientation as well.