Swift tab bar view prepareforsegue

前端 未结 1 1775
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-18 00:58

In VC1 (collection view) this is my prepareforsegue code:

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
    let segue = segue         


        
相关标签:
1条回答
  • 2020-12-18 01:39

    Have you checked whether the prepareForSegue in your TabBarController ever gets called?

    It would never be called since the connection between a UITabBarController and its children view controllers isn't a storyboard segue. You should get a reference directly to the viewController from the UITabBarController by accessing its viewControllers collection at the index you want.

    var tabBarController = segue.destination as UITabBarController
    var destinationViewController = tabBarController.viewControllers[0] as YourViewController // or whatever tab index you're trying to access
    destination.property = "some value"
    
    0 讨论(0)
提交回复
热议问题