0
votes

My app works with tabbarcontroller as root view of the window, where on clicking each tab item loads splitviewcontroller with required views for it. The left and right panes of split views are navigation controllers. Now on any button action or didselectrow in tableview corresponding views are to be loaded in right pane. I succeeded loading views in right pane , but not able to display barbuttonitem when new view controller loaded in right pane of split view.

tabbarcontroller

-->splitviewcontroller

----->Leftpane:navigation controller

--------------->view controllers

----->Rightpane:navigation controller

--------------->view controller

Each Splitview of tab bar wil act like 'iPad Mail app' .

To make the app gernalised, I taken class RootiPadViewController which has the delegate of uisplitviewcontroller and uipopovercontroller which loads alls views in slpitview.

Loaded viewcontroller in right pane of split view as below.

UISplitViewController *splitViewController = (UISplitViewController*)[appDelegate.tabBarController.viewControllers objectAtIndex:tabIndex];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:viewController];
//[navController pushViewController:viewController animated:YES];

NSMutableArray *array = [[NSMutableArray alloc] init];
[array addObject:[splitViewController.viewControllers objectAtIndex:0]];
[array addObject:navController];
splitViewController.viewControllers = array;
[array release];

Please suggest me why bar button item not displayed when views changed in splitviewcontroller.

App looks as belowenter image description here

enter image description here

3

3 Answers

0
votes

I may be wrong but from my knowledge, the bar button item should appear only when you are in portrait mode, because:

  • a split view controller has two controllers (master and detail view controller)
  • both view controllers are shown on the screen when you are in landscape mode
  • when you are in portrait mode, only the detail view controller is shown, thus the bar button item appears
  • the bar button item goal is to let you open the master view controller in portrait mode

Please let me know if that helps you.

0
votes

For Navigation Controller each view should define their left and right bar buttom items, if nothing defined then the tabbar will be empty . The only barbutton Item you will get free is the back barbutton item which appeared when you push a new View Controller above the rootViewController of the navigationController

You have to to allocate them in your ViewDidLoad method of each viewController in the NavigationControoler and set them as right and left barbutton item of your parentViewController(ie navigationController)

0
votes

Please check this sample project https://github.com/alexth/TBSV

It's about how to use UISplitViewController inside UITabBar. All logic is in Appdelegate's -loadSplitToTab Just total inheriting of all controllers, in every other cases UISplitViewController needs to be a root (as described in Apple documents) and you will not be able to use UISplitViewController inside UITabBar.