【问题标题】:Linking from UIViewcontroller to UITabBarController page从 UIViewcontroller 链接到 UITabBarController 页面
【发布时间】:2012-10-31 22:22:54
【问题描述】:

我有一个链接问题,我使用的是 xib,而不是故事板。

我有一个 UITabBarController 系统和一些其他视图控制器,它们远离标签栏系统。我的问题是我可以使用按钮从其中一个视图控制器链接回 UITabBarController 上的某个页面吗?

【问题讨论】:

    标签: xcode uiviewcontroller uitabbarcontroller


    【解决方案1】:

    UITabBarController 是父级,标签下的 ViewController 是子级。您可以使用 parentViewController 属性从 childViewControllers 访问 TabBarController。

    因此,如果您有一个带有 2 个选项卡的 UITabBarController,其中包含 ViewController1 和 ViewController2,您可以在其中任何一个中使用此行。

    UITabBarController* tabBarController = (UITabBarController*)self.parentViewController;
    // So if for example you have a button in ViewController2 and you need to show
    // ViewController1 when it is pressed, you can do the following
    tabBarController.selectedIndex = 0;
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-04-10
    • 2019-04-16
    • 1970-01-01
    • 2021-07-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-03
    相关资源
    最近更新 更多