How to add tab bar controllers to the root view of the split view controller application

前端 未结 3 1592
礼貌的吻别
礼貌的吻别 2021-01-06 16:42

\"enter

I am very new to the iPad UISplitViewController.

I need

相关标签:
3条回答
  • 2021-01-06 16:54

    you have to take UITabBarController dynaically.

    In .h file

    UITabBarController *tabBar;

    in .m file

    create objects to your classes in appDidFinish Launch

    For example you have

    Class1 and Class2

    in appDidFinishLaunch

    Class1 *obj1=[Class1 alloc]initWithNibName:@"Class1" bundle:nil]; **Class2 obj2=[Class2 alloc]initWithNibName:@"Class2" bundle:nil];*

    // Master navigation controller by defaults comes with template code

    // Now you have create Array for tabBar

    NSArray *tabViewArray=[[NSArray alloc] initWithObjects:obj1,obj2,masterNavigationController, nil];

    tabBar=[[UITabBarController alloc] init];

    [tabBar setViewControllers:tabViewArray];

    // now you have to edit the statement which contains splitview.viewArray repalce masterNavigataionControler with tabBar

    self.splitViewController.viewControllers = [NSArray arrayWithObjects:tabBar, detailNavigationController, nil];

    Try this i hope it will helps you.

    0 讨论(0)
  • 2021-01-06 17:08

    in your app delegate add tabbar controller then add your view controllers to tabbar controller and set the window rootview controller to tabbar controller.

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
     self.tabbar=[[UITabBarController alloc] init];
    
       self.vc1 = [[vc1 alloc] initWithNibName:@"ViewController_iPhone" bundle:nil];
       // do the same to other VCs
        self.tabbar.viewControllers=[NSArray arrayWithObjects:vc1,vc2,vc3,vc4, nil];
    
    
    self.window.rootViewController = self.tabbar;
    
    [self.window makeKeyAndVisible];
    return YES;
    

    }

    i hope it helps :-)

    0 讨论(0)
  • 2021-01-06 17:10

    All you have to do is initialize the first argument of uispliviewcontroller for view as tabbar instead of a view or you can use uisegmentedcontrol.

    0 讨论(0)
提交回复
热议问题