【问题标题】:Simple TabBar on a View for 2 Other views?2个其他视图的视图上的简单TabBar?
【发布时间】:2011-11-06 14:44:27
【问题描述】:

我想要一个带有 TabBar 的 SettingViewMain,它可以在 SettingView1 和 SettingView2 之间切换。

我尝试了这个简单的工作 3 个小时,并尝试了我找到的几乎所有教程,但我没有让它工作。

当我尝试以编程方式添加 TabBar 时,我可以在这 2 个视图之间切换,但是在这个视图本身中,TabBar 没有显示,不知道为什么。当我添加 TabBarController 时,根本不显示。

那么,简单来说:如何在 MasterView(不是 AppDelegate-Window 或类似的东西)上添加 TabBar 并让 TabBar 在 View1 和 View2 之间切换?

【问题讨论】:

    标签: iphone ios tabbar tabbarcontroller


    【解决方案1】:

    您可以使用其 alloc 和 init 方法来实例化 UITabBarController。 实例化其他两个 ViewController 并将它们添加到数组中。 这样做之后,将它的视图添加到您的“MasterView”中。

    代码:

    UITabBarController *tab = [[UITabBarController alloc] init];
    UIViewController *controller1 = [[UIViewController alloc] init];
    UIViewController *controller2 = [[UIViewController alloc] init];
    
    NSArray *controllers = [[NSArray alloc] initWithObjects:controller1, controller2, nil];   
    [tab setViewControllers:controllers];
    
    [[self view] addSubview:[tab view]];
    

    或与之相近的东西。

    祝你好运!

    布莱恩

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-11-08
      • 2021-01-05
      • 1970-01-01
      • 1970-01-01
      • 2019-11-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多