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

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

    With Swift:

    if let navController = self.tabBarController?.viewControllers?[1] as? UINavigationController{
            if let testController = navController.childViewControllers.first as? MyViewController{
                testController.data = data
                self.tabBarController?.selectedIndex = 1
            }
    }
    

提交回复
热议问题