OGeek|极客世界-中国程序员成长平台

标题: ios - 如何在 AppDelegate 中获取 Storyboard UITabBarController 的指针 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 08:55
标题: ios - 如何在 AppDelegate 中获取 Storyboard UITabBarController 的指针

我正在使用 Storyboard 来创建我的应用程序。我的应用程序的根目录是一个 UITabBarController。如何从我的应用程序委托(delegate)中访问我的 tabBarController?我设法从我的一个 UIViewControllers 中成功地实现了这些操作。但我想将代码移动到我的应用程序委托(delegate)。我怎么能做到这一点?我以为我可以从 Storyboard 拖放到我的应用委托(delegate)并得到类似的东西

@property (nonatomic, strong) IBOutlet UITabBarController *tabBarController;

但这似乎不是目前的选择。



Best Answer-推荐答案


UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;

关于ios - 如何在 AppDelegate 中获取 Storyboard UITabBarController 的指针,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25318116/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4