How do I pass data from a tab bar controller to one of its tabs?

后端 未结 6 781
滥情空心
滥情空心 2021-02-02 09:21

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 UIVie

6条回答
  •  遇见更好的自我
    2021-02-02 10:14

    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.

    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!

提交回复
热议问题