如何将标签栏控制器中的数据传递到其中一个选项卡? [英] How do I pass data from a tab bar controller to one of its tabs?

查看:200
本文介绍了如何将标签栏控制器中的数据传递到其中一个选项卡?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在故事板中设置了UITabBarController。我想从选项卡栏控制器传递一个数据字典,以便在相应的子选项卡中使用,这是一个标准的UIViewController。

I have a UITabBarController set up in storyboard. I want to pass a dictionary of data from the tab bar controller for use in the appropriate child tab, which is a standard UIViewController.

这似乎是一个很长的问题要回答,但我真的不知道从哪里开始。我正在寻找最简单的方法。我必须以编程方式使标签功能化吗?我也非常感谢指向任何有用的开发者文档。

This seems like a long questions to answer, but I really don't know where to start. I'm looking for the easiest way through this. Must I make the tabs function programmatically? Pointing me towards any useful developer documentation would also be much appreciated.

-Austin

p.s.我是新手,到目前为止依赖故事板进行视图控制器转换

-Austin
p.s. i'm new and have so far depended on storyboard for viewcontroller transitions

推荐答案

花了几天时间,但我发现了简单解决方案在我的TabBarController的viewDidLoad方法,我可以访问,并设置使用

It took a couple of days, but I discovered a simple solution. In my TabBarController's viewDidLoad method, I can access and set attributes of my the tabbed subviews using

    [[self viewControllers] objectAtIndex:0]

或您希望访问的任何索引。

or whatever index you wish to access.

保存它作为我的tab1_viewController的一个实例给了我一个指向该对象的指针,我可以从中获取并设置我的属性值。这最初不清楚,因为storyboard为我创建了tab_viewController对象。我没有机会按照我想要的方式初始化它们!

Saving that as an instance of my tab1_viewController gives me a pointer to the object, from which I can get and set my property values. This was initially unclear because storyboard created the tab_viewController objects for me. I never had a chance to initialize them the way I wanted to!

这篇关于如何将标签栏控制器中的数据传递到其中一个选项卡?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆