帮助我解决需要在 mainwindow.xib 中完成的连接,以便标签栏控制器在标签栏项目之间切换。我已将应用程序委托连接到选项卡栏控制器。但是当点击标签栏按钮时,我无法切换多个视图
问问题
47 次
1 回答
0
假设您的 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。
于 2011-12-15T05:36:38.517 回答