Search code examples
swiftsegueuistoryboardsegue

How to segue from More tabBarController to child viewController?


I have a tab bar app with 6 tab bar items [News, Chats, Services, Notifications, Profile, Events]
Automatically, the last item will be transformed in a More item.
Now, Profile and Events will show in a tableViewController when More is tapped.

Events has 5 childViewControllers.

My questions is: how can I segue from Events to any of its children? Every time, I try to segue, it outputs error reason: 'Receiver (<UIMoreNavigationController: 0x7fb0f1814e00>) has no segue with identifier 'fromEventsVcToEventsComposer'' The identifier is correct.

What have I tried?

self.navigationController?.performSegue(withIdentifier: "fromEventsVcToEventsComposer", sender: nil)

self.tabBarController?.moreNavigationController.performSegue(withIdentifier: "fromEventsVcToEventsComposer", sender: nil)    

Solution

  • You can try

    if let events = self.tabBarController?.moreNavigationController.viewControllers?.last as? EventsVC { 
      events.performSegue(withIdentifier: "fromEventsVcToEventsComposer", sender: nil)  
    }