我有一个链接问题,我使用的是 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/