我有一个故事板,从UINavigationController开始,然后是UIViewController,从这个UIViewControllerUITabbarController只是一个标记。我需要这个UITabbarController参考,但是从另一个视图控制器中,我该如何获得呢?

最佳答案

您可以使用情节提要ID来实现。将一个情节提要ID设置为TabBarController。

这是您可以在任意位置调用的代码。

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"nameOfStoryboard" bundle:nil];


TabBarController * destViewController = [storyboard instantiateViewControllerWithIdentifier:@"TheIDOfTabBarController"];

[self.navigationController pushViewController:destViewController animated:YES];

07-28 01:31
查看更多