gpt4 book ai didi

xcode - 从 UIViewcontroller 链接到 UITabBarController 页面

转载 作者:行者123 更新时间:2023-12-04 05:59:56 26 4
gpt4 key购买 nike

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

我有一个 UITabBarController 系统和其他一些远离标签栏系统的 View Controller 。我的问题是我可以使用按钮从其中一个 View Controller 链接回 UITabBarController 上的某个页面吗?

最佳答案

UITabBarController 是父级,选项卡下的 ViewControllers 是子级。您可以使用 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;

关于xcode - 从 UIViewcontroller 链接到 UITabBarController 页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13344660/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com