gpt4 book ai didi

ios - 我无法访问 tabbarcontroller 下的 View Controller

转载 作者:行者123 更新时间:2023-11-29 12:56:15 25 4
gpt4 key购买 nike

我有一个带有 3 个 subview 的 tabbarcontroller。在 IB 中,我将 3 个导航 Controller 连接到 tabbarcontroller,然后我连接到每个导航 Controller ,一个 tableviewcontroller。我有我想从根 tabviewcontroller 设置的公共(public)属性。

我的问题是..1)这是设置层次结构的正确方法吗?我听说你不应该在导航 Controller 中嵌入 tabbarcontroller,所以我为我需要的每个 tableviewcontroller 制作了 3 个导航 Controller 。

2) [AITBC 描述] 为空:/

NSArray *viewControllers = [self.tabBarController viewControllers];
AllItemTableViewController *AITBC = (AllItemTableViewController *)[viewControllers[0] rootViewController]; //[viewControllers[0] should be the first navigation controller, so I want its root view controller right?
AITBC.AllGroomedItemsArray = self.allGroomedData;

最佳答案

你不能访问你的 View Controller 的原因是因为你甚至没有将你的 tabBarController 链接到某种代码以便你继续做一些时髦的事情。

要将界面构建器的 tabBarcontroller 链接到您的代码,只需创建您自己的 TabBarViewController 类,将其称为 MyTabBarViewController,然后将该类链接到界面构建器文件中的 TabBarViewController。

完成后,您将能够从新类访问标签栏 View Controller 。

或者您可以通过代码完成此操作,您可以在您的应用委托(delegate)中添加一个 tabBarViewController 属性,然后将 windows.rootViewcontroller 链接到该属性以在您的界面生成器中访问您的 tabBarViewcontroller,而无需在 IB 中直接链接任何内容。但是,正如对话聊天线程中所讨论的那样,您对在您的应用委托(delegate)中包含任何代码表现出不感兴趣。

你也有 [self.tabBarController viewControllers] 而你可以用 self.viewControllers 代替。

关于ios - 我无法访问 tabbarcontroller 下的 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21007818/

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