【问题标题】:Navigation Bar & Navigation Toolbar NOT from App Delegate导航栏和导航工具栏不是来自 App Delegate
【发布时间】:2014-05-19 11:14:55
【问题描述】:

我是 xcode ios 7 的新手。 我在为 iPhone ios7 构建应用程序的导航控件方面遇到了很多困难。 我不想使用故事板。我更喜欢以编程方式进行。

我想做什么。

我知道如何通过AppDelegate.m 创建NavigationBarNavigation Toolbar

但如果可能的话我不想这样做,因为假设我希望在 FirstViewController 中只显示简单的按钮“转到第二个视图控制器”(此处没有导航栏或工具栏) .

现在在 SecondViewController 我想创建导航工具栏(底部),其中有 4 个不同的选项卡链接到 ViewControllers

但诀窍是,我想为每个 ViewController 维护不同的导航栏(顶部)(如您在此屏幕截图中所见)。

这是我的Xcode Project File

这里是 Fancy 应用程序的屏幕截图,显示了我想要实现的目标。

提前非常感谢!

【问题讨论】:

    标签: ios cocoa-touch ios7 xcode5


    【解决方案1】:

    只是给您一个想法,当您点击第一个视图控制器上的按钮时,您可以创建一个 UINavigationController 并将您的第二个视图控制器设置为其根视图控制器。这样,您的第一个视图控制器仍然没有导航栏视图,而第二个视图控制器拥有一个导航控制器。试试下面的方法:

    -(IBAction)goToSecondVC:(id)sender // An action for the button in your first VC
    {
        SecondViewController *secondVC = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil]; //Init with second view controller
        UINavigationController *secondNavVC = [[UINavigationController alloc] initWithRootViewController:secondVC]; // create a navigation controller and set the root as your second view controller
        [self presentViewController:secondNavVC animated:YES completion:nil]; // and then present it with anim or no anim..
    }
    

    【讨论】:

    • 大声笑。有趣的想法我会尝试。
    猜你喜欢
    • 2015-12-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多