【问题标题】:Adding UINavigationController to xCode Tab Bar Application Template将 UINavigationController 添加到 xCode 选项卡栏应用程序模板
【发布时间】:2011-11-11 19:19:01
【问题描述】:

如何将 UINavigationController 添加到 xCode Tab Bar Application Delegate?

我的结构基于 xCode Tab Bar Application Delegate,有 2 个选项卡,分别是第一个视图和第二个视图。对于第一个视图,我添加了一个 UITableView。我只想利用 UINavigationController 函数[self.navigationController pushViewController:animated:] 推送子视图并允许在子视图中显示导航栏。推送子视图后,标签栏必须还在。

听起来很简单,但我不知道如何实现。请帮忙。

【问题讨论】:

    标签: ios4 xcode4 uinavigationcontroller uitabbarcontroller


    【解决方案1】:

    我从一个基于 Window 的模板开始,并这样做是为了达到同样的目的。

    我在我的应用委托中手动创建了NavigationControllersTabBarController

    在你的:

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    

    添加这个:

    //Seeting up the Navigation controllers and pushing our TableView controllers.  
    UINavigationController *unvc1 = [[UINavigationController alloc] init];
    UINavigationController *unvc2 = [[UINavigationController alloc] init];
    [unvc1 pushViewController:someViewController1 animated:NO];
    [unvc2 pushViewController:someViewController2 animated:NO];
    [someViewController1 release];[someViewController2 release];//Releasing our TableView controllers. 
    
    //Setting up the TabBar controller and pushing our Navigation controllers. 
    UITabBarController *tbvc = [[UITabBarController alloc] init];
    tbvc.viewControllers = [NSArray arrayWithObjects:unvc1, unvc2, nil];
    [unvc1 release];[unvc2 release]; //releasing our Navigation controllers. 
    

    我希望这会有所帮助。

    【讨论】:

    • 有界面生成器解决方案吗?
    • 当然,但不幸的是我没有使用该模板,所以我这样设置它。我知道这不是你想要的,但它会帮助你前进。此外,任何被推入NavigationControllerTabBarConrtollerViewController,都可以使用IB 创建。
    【解决方案2】:

    我使用 presentModalViewController:animated 做到了这一点。我在 modalView 中添加了 tabBar 控制器。在方法 didSelectRowAtIndexPath 中使用这个 presentModalViewController:animated 。我可能并不完美,但我遇到了同样的问题,但现在我的应用程序可以正常工作了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-12-18
      • 2011-02-04
      • 1970-01-01
      • 2016-12-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多