Search code examples
objective-ciosipaduitabbarcontrolleruisplitviewcontroller

TabBarController and SplitViewController


i want my splitviewController to be displayed in within a TabBarController. Unfortunately, I firstly decided to just have a SplitViewController and chose apple's template. Now i am in the inconvenient position not knowing how to add it to a tab bar.

I tried several stuff that was explained here on StackOverflow but the best result was a black screen with a tab bar below it :-(

I am just struggling to find a nice and simple way.

Code of my Appdelegate:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{
// Override point for customization after application launch.
// Add the split view controller's view to the window and display.
self.window.rootViewController = self.splitViewController;
[self.window makeKeyAndVisible];

NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
documentFolderPath = [searchPaths objectAtIndex: 0];
self.rootViewController.directoryPath = documentFolderPath; 

NSURL *docUrl = [launchOptions objectForKey:UIApplicationLaunchOptionsURLKey];
if ([docUrl isFileURL]) {
    NSString *path = [docUrl path];
    self.detailViewController.currentFilePath = path;
    [self.detailViewController setDetails:path newFile:FALSE];
}
return YES;

Solution

  • From Apple's documentation this is a no no situation.

    But there is a way to achieve this easily (we did it for an application).

    have a look at http://www.codeworth.com/blog/mobile/ios-splitviewcontroller-inside-tabviewcontroller/

    I think this would be the apt answer for the question.