SplitViewController with TabbarController

2020-05-09 01:12发布

I am using the split View functionality in my app.I have to put tabbar in rootViewController.

But when I add controllers in tabbar and add them into split view it doesnt split.

It only shows detailViewController.

Here is the code in application did finish launching:

- (void)applicationDidFinishLaunching:(UIApplication *)application {

    UIViewController  *viewController2,*viewController3,*viewController4;
    rootViewController = [[[CategoryItemsList alloc] init] autorelease];
    viewController2 = [[[SearchList alloc] init] autorelease];
    viewController3 = [[[FavoritesList alloc] init] autorelease];

    viewController4 = [[[Information alloc] init] autorelease];

    self.tabBarController = [[[UITabBarController alloc] init] autorelease];
    self.tabBarController.viewControllers = [NSArray arrayWithObjects:  rootViewController,viewController2,viewController3,viewController4, nil];

    splitDetail = [[splitDetailView alloc] initWithNibName:@"splitDetailView" bundle:nil];

    UINavigationController *nav=[[UINavigationController alloc] initWithRootViewController:tabBarController];

    splitViewController = [[UISplitViewController alloc] init];
    // splitViewController.tabBarItem = controller.tabBarItem;
    splitViewController.viewControllers = [NSArray arrayWithObjects:nav, splitDetail, nil];
    splitViewController.delegate=splitDetail;
    rootViewController.splitView=splitDetail;
}

1条回答
Anthone
2楼-- · 2020-05-09 01:52

You can refer to this links. I think this is what you are looking out for:

https://github.com/mattgemmell/MGSplitViewController

http://www.raywenderlich.com/1040/ipad-for-iphone-developers-101-uisplitview-tutorial

http://mikebluestein.wordpress.com/2010/04/03/using-a-uisplitviewcontroller-to-create-a-master-detail-ipad-app-with-monotouch/

Once you add the split view then you just need to add the object of the SplitViewController to the TabBarController as one of the viewControllers

Hope this helps.

查看更多
登录 后发表回答