您可以通过编程方式检索 TabBarApp 中选项卡的名称吗?
我在 Interface Builder 中创建了一个 tabBar 应用程序 - 并在那里命名了我的所有选项卡和选项卡项。我现在可以在运行时以编程方式查找或检索选项卡的名称吗? 当我对 viewControllers 数组执行 NSLog 时,我得到的只是:
( "", "", "", "", ”” )
这显然不好——我需要获得更具体的信息。
另外,我注意到您无法将 IB 中的标签、标题或标签设置到选项卡中的任何视图控制器。
那么,如何通过代码识别各个选项卡中的内容呢?或者您是否必须放弃 Interface Builder 并通过代码完成所有操作?
I created a tabBar app in Interface Builder - and named all my tabs and tab-items there. Can I now programmatically find out or retrieve the names of my tabs during run-time?
When I do an NSLog of the viewControllers array, all I get is:
(
"",
"",
"",
"",
""
)
That's obviously no good - I need to get more specific info.
Also, I noticed you can't set a tag, title or label in IB to any of the view-controllers in your tabs.
So how can you identify through code what you have sitting in your various tabs? Or do you have to ditch Interface Builder and do everything by code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
每个视图控制器中的选项卡栏项目包含标题。
话虽如此,我认为引用特定选项卡的最佳方法是从应用程序委托到每个视图控制器具有显式的 IBOutlet。由于不会超过少数,所以这不应该有太多额外的代码。
The tab bar item within each view controller contains the title.
Having said that, I think the best way to refer to specific tabs is to have explicit
IBOutlet
s from the app delegate to each view controller. Since there's not going to be more than a handful, this shouldn't be too much extra code.