ios - 如何从第二个 View Controller 添加标签栏 Controller

标签 ios objective-c cocoa-touch ios6

<分区>

我是 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/

上一篇:ios - 显示来自 facebook 的照片

下一篇:ios - 我的 MBProgress HUD 和 JSON 方法 - 改进代码的帮助/指导

相关文章:

ios - 我希望我的应用程序能够识别 iPhone 型号,因为我没有使用自动布局

objective-c - 平衡保留与释放?

ios - 在启用了 UserInteractionEnabled 的情况下禁用 UILabel 上的复制

javascript - React Native 集成测试总是通过(即使它们不应该通过)

xcode - 显示评分星星 xcode

ios - swift MapKit 不显示注释引脚

mysql - 如何将图像从 Drupal 字段加载到 UIImageView?

iOS - 从 TableView 单元格重新加载元素

ios - 使用核心数据进行应用程序设置

ios - 如何以编程方式在 iOS 中从右向左移动文本