<分区>
<分区>
我是 IOS 应用程序开发学习的初学者。 我有一个登录屏幕作为我的第一个 View Controller ,我需要第二个 View Controller 作为标签栏 View Controller 。有 4 个不同的选项卡,我有 4 个不同的 XIB。
有人帮助我继续前进。
最佳答案
最好的方法是当应用程序从标签栏 Controller 第一个屏幕启动时以模态方式显示登录屏幕,在 viewWillAppear 中添加用于显示登录屏幕的代码,并在登录后关闭屏幕。您可以像这样在 appDelegate 中创建 TabBarController
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UITabBarController tabBarController=[[UITabBarController alloc] init];
FirstViewController *firstVC = [[UIViewController alloc] initWithNibName:@"FirstVC" bundle:nil];
UINavigationController *firstNavController = [[UINavigationController alloc] initWithRootViewController: firstVC];
SecondViewController *secondVC = [[UIViewController alloc] initWithNibName:@"secondVC" bundle:nil];
UINavigationController *secondNavController = [[UINavigationController alloc] initWithRootViewController:secondVC];
tabBarController.viewControllers = [NSArray arrayWithObjects: firstNavController, secondNavController, nil];
tabBarController.selectedIndex=0;
tabBarController.delegate = self;
UITabBarItem *item1 = [[UITabBarItem alloc] initWithTitle:@"Movies" image:[UIImage imageNamed:@"MoviesTAB.png"] tag:1];
[firstVC setTabBarItem:item1];
UITabBarItem *item2 = [[UITabBarItem alloc] initWithTitle:@"Music" image:[UIImage imageNamed:@"musicTAB.png"] tag:2];
[seconfVC setTabBarItem:item2];
tabController.tabBar.translucent = NO;
tabController.tabBar.barStyle = UIBarStyleBlack;
tabBarController.tintColor = [UIColor whiteColor];
self.window.rootViewController = tabController;
return YES;
}
关于ios - 如何从第二个 View Controller 添加标签栏 Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19926353/