0

I currently have a MasterDetail view app that I would like to add a Tab Bar to. I have added the tab bar successfully to the Master tableview and I have a table view set to be the other tab. This is working, but my question is:

If I want to have another MasterDetail View on the other tab, would I add a SplitView Controller to the Tab Bar Controller? Or would I just add a table view controller, size it to Master, and then add a UIView and size it to detail and push all of the data via segue?

Might be a dumb question, but I haven't seen any answers on this yet.

*EDIT*

Here is the contents of my AppDelegate.m so far:

#import "AppDelegate.h"
#import "LeftViewController.h"
#import "RightViewController.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    UISplitViewController *splitViewController = (UISplitViewController   *)self.window.rootViewController;
    UINavigationController *leftNavController = [(UITabBarController *)splitViewController.viewControllers[0] viewControllers][0];
    LeftViewController *leftViewController = (LeftViewController *)[leftNavController topViewController];
    UINavigationController *rightNavController = [splitViewController.viewControllers objectAtIndex:1];
    RightViewController *rightViewController = (RightViewController *)[rightNavController topViewController];

    Player *selectedPlayer = [[leftViewController players]objectAtIndex:0];
    [rightViewController setPlayer:selectedPlayer];

    leftViewController.delegate = rightViewController;
    return YES;
}

- (void)applicationWillTerminate:(UIApplication *)application
{
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
CaptJak
  • 3,542
  • 1
  • 25
  • 48

1 Answers1

0

Your UITabBarController should be the root view controller in your app, then each of the tab bars viewControllers could be a UISplitViewController or whatever suits your needs.

I'd show you a picture of storyboard, but there's too much stuff on it to tell what's going on!

Hope that helps.

-- UPDATE --

It won't necessarily be quite that easy, but you should be able to accomplish what you are after with minimal work. View controllers can be moved around without needing to redo the app. Take the following example and see if it helps. Basically, you'll need a UITabBarController as your root view controller and you can add the split views into it:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.

    self.tabController = [[UITabBarController alloc] init];

    self.splitView = [[UISplitViewController alloc] init];

    self.tabController.viewControllers = @[self.splitView];

    self.window.rootViewController = tabController;

    return YES;
}

Obviously your code will be different, but this basic example should get your going in the right direction.

Dan Fairaizl
  • 2,132
  • 2
  • 27
  • 30
  • Well, My app is already half done, so I don't want to start over. Would this be as simple as changing the `UISplitViewController *splitViewConroller = (UISplitViewController *)self.window.rootViewController` to UITabBarController? Where is the ideal place to put the SplitViewController if I have moved it out of the RootView? – CaptJak Jul 07 '13 at 16:31
  • @CaptJak, updated the answer. Hopefully that helps. Let me know if! – Dan Fairaizl Jul 07 '13 at 19:51
  • sorry, but now I am just confused! I added my current AppDelegate.m to show you what I am working with right now. How will the code you presented work in there? – CaptJak Jul 07 '13 at 20:08
  • Are you using storyboards or nibs? If so this will become a lot easier. – Dan Fairaizl Jul 08 '13 at 14:33
  • Storyboard, sorry for not mentioning earlier – CaptJak Jul 08 '13 at 14:39
  • any thoughts? I am using Storyboards. – CaptJak Jul 10 '13 at 00:57