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

后端 未结 6 785
滥情空心
滥情空心 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:25

    Got this working...

    I have 3 view controller, I have to pass the array from one to another..

    Here is what I did

    Appending the data to one of Tab View Controller

    NSArray *viewControllers = [self.tabBarController viewControllers];
        ListViewController *listView = (ListViewController *)viewControllers[1];
        listView.myArray = self.myArray;
        [self.tabBarController setSelectedIndex:1];
    

    And after that, load the view controller, that's it

    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
    ListViewController *listView = (ListViewController *)[storyboard instantiateViewControllerWithIdentifier:@"IDListView"];
    

提交回复
热议问题