How can I create a UISplitViewController in a tab bar (iPad) app?

I have seen several applications that use UISplitViewController

inside a tab. This is exactly what I need to do, but I have several problems.

So far I have done the following:

In my application delegate class ...

// Set up the cuts tab
UIViewController *splitViewController = [[SplitViewController alloc] initWithNibName:@"SplitViewController" bundle:nil];

// Set up the tab bar
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:splitViewController, nil];


Then SplitViewController.h

there is ...

#import <UIKit/UIKit.h>

@class LeftView;
@class RightView;

@interface SplitViewController : UIViewController
    UISplitViewController *splitView;
    LeftView *leftView;
    RightView *rightView;

@property(nonatomic, retain)IBOutlet UISplitViewController *splitView;
@property(nonatomic, retain)IBOutlet LeftView *leftView;
@property(nonatomic, retain)IBOutlet RightView *rightView;



Then in the corresponding .m file there is ...

#import "SplitViewController.h"

@implementation SplitViewController
@synthesize splitView, leftView, rightView;

#pragma mark - View Lifecycle

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) 
        self.title = @"Tab A";
        self.tabBarItem.image = [UIImage imageNamed:@"My_Icon"];
    return self;

- (void)viewDidLoad
    [super viewDidLoad];

    self.view = splitView.view;

- (void)viewDidUnload
    [super viewDidUnload];

    self.splitView = nil;
    self.leftView = nil;
    self.rightView = nil;

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    return YES;



The next thing I did was create a class UITableViewController

for leftView

and UIViewController

for rightView


Finally, I linked IBOutlets

with the relevant components and tried to get it running. However, when I launch the application, everything sees a black screen where I expect to see UISplitViewController


I'm totally stumped, so any help would be really appreciated.


To be more specific, I followed this tutorial up to the ' Creating Our Model ' section , where I left off because it was UISplitView

n't showing up.


source to share

2 answers

Check out IntelligentSplitViewController .



I know this is the answer, but I recently solved this in iOS6. I tried to implement IntelligentSplitViewController but couldn't get it to work all the time - perhaps because I was targeting iOS6. Basically my solution involved subclassing both UISplitViewController and UITabBarController and handling rotation events. I detail my solution in this blog post . Hope this helps.



All Articles