【问题标题】:Xcode sub navigation viewsXcode 子导航视图
【发布时间】:2013-10-08 21:18:07
【问题描述】:

请问有谁知道以下的好教程吗?

我是 Xcode 新手,不知道从哪里开始。

我有一个 ViewController,它是根视图,上面有 6 个导航按钮 (UIButton)。根据单击的按钮,用户将看到该部分的子导航视图,其中包含更多按钮选项。

例如,顶层将有按钮去哪里吃饭,做什么...... 然后点击 Where to Eat 将显示餐馆、快餐 ....等

我想以编程方式执行此操作。我可以使用 Storyboards 并使用多个视图来做到这一点,但它会变得非常混乱,因为最终屏幕上有很多视图。

我已经按照教程 HERE 了解如何为 TableViewControllers 完成它,但我需要类似的按钮。

我不确定这个函数叫什么——最近一段时间一直在搜索子导航,但没有什么比得上我需要完成的。

【问题讨论】:

    标签: iphone objective-c button navigation xcode5


    【解决方案1】:

    查看 UIViewController 的方法 presentViewController:animated:completion: 方法。它在 iOS 5.0 及更高版本中可用。假设您有一个按钮链接到运行 buttonOneActivated: 方法:

    -(IBAction)buttonOneActivated:(id)sender
    {
        UISubViewController *subViewController = [[UISubViewController alloc] init];
    
        [self presentViewController:subViewController
                           animated:YES
                         completion:NULL];
    }
    

    在 UISubViewController 的实现中,假设您有另一个按钮来返回父级:

    -(IBAction)returnToParent:(id)sender
    {
        [[self presentingViewController] dismissViewControllerAnimated:YES
                                                            completion:NULL];
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-05-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-05
      • 2019-02-21
      • 1970-01-01
      相关资源
      最近更新 更多