【发布时间】:2012-01-20 21:08:38
【问题描述】:
帮助我解决需要在 mainwindow.xib 中完成的连接,以便标签栏控制器在标签栏项目之间切换。 我已将应用程序委托连接到选项卡栏控制器。 但是单击标签栏按钮时无法切换多个视图
【问题讨论】:
标签: iphone eclipse iphone-sdk-3.0 iphone-sdk-3.2 tabbarcontroller
帮助我解决需要在 mainwindow.xib 中完成的连接,以便标签栏控制器在标签栏项目之间切换。 我已将应用程序委托连接到选项卡栏控制器。 但是单击标签栏按钮时无法切换多个视图
【问题讨论】:
标签: iphone eclipse iphone-sdk-3.0 iphone-sdk-3.2 tabbarcontroller
假设您的 tabBarController 上有 2 个选项卡。
在您的 appDelegate 函数中
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UIViewController *viewController1 = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
UIViewController *viewController2 = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2,nil];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
}
这样你就可以轻松地绑定你的tabBarController。 注意:不要忘记在 appDelegate.h 文件中声明 tabBarController。
【讨论】: