向标签栏添加额外的选项卡按钮

时间:2012-08-01 11:55:03

标签: objective-c ios xcode

我在XCode中启动了一个新的Tabbed应用程序,我想知道在给定的Tab Bar中添加额外按钮的最佳方法是什么?

谢谢!

2 个答案:

答案 0 :(得分:0)

根据Xcode 4.3.3当我们创建选项卡式应用程序时,它会给出两个ViewController。因此,如果您想要添加更多内容,您可以进入AppDelegate,您可以看到

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
UIViewController *viewController1 = [[[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil] autorelease];
UIViewController *viewController2 = [[[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil] autorelease];
self.tabBarController = [[[UITabBarController alloc] init] autorelease];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2, nil];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
return YES;
}

你可以看到在tabBarController中添加了两个ViewController,你可以创建一个新的,并添加init作为1或2添加。 试试.......

答案 1 :(得分:0)

以下是我认为可以解答您的答案的视频:here

但有时候'最好'可能是主观的。要么使用'故事板',要么按照Berry M的描述去代码路线。