如何以编程方式创建标签栏 [英] how to create tabbar programmatically

查看:66
本文介绍了如何以编程方式创建标签栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好, 我有一个基于导航的应用程序,其中我也需要在一种视图中实现选项卡栏. 在一种视图中,我需要5个标签,可以有人建议我以编程方式创建标签栏吗?每个标签都应导航到另一个xib.

HI all, i am having navigation based application, in which i need too implement tab bars ,in one of view. in one view i need 5 tabs, can any one please suggest me to create tab bars programmatically,, ? each tab should navigate to another xib.

建议总是值得赞赏的. 问候

Suggestions are always appreciated. regards

推荐答案

下面是Apple的示例代码,用于以编程方式创建标签栏:

Here is a sample code from Apple to create tab bar programmatically:

- (void)applicationDidFinishLaunching:(UIApplication *)application {
   tabBarController = [[UITabBarController alloc] init];

   MyViewController* vc1 = [[MyViewController alloc] init];
   MyOtherViewController* vc2 = [[MyOtherViewController alloc] init];

   NSArray* controllers = [NSArray arrayWithObjects:vc1, vc2, nil];
   tabBarController.viewControllers = controllers;

   // Add the tab bar controller's current view as a subview of the window
   [window addSubview:tabBarController.view];
}

查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆