我有一个链接问题,使用xib,而不是故事板.
我有一个UITabBarController系统和一些远离标签栏系统的其他视图控制器.我的问题是我可以使用按钮将其中一个视图控制器链接回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;