Dracris
Dracris

Reputation: 93

Chain two segues to look like one

I have this structure in story board (lines represents segues):

    B    
   /
  A
   \
    C

I want to use A (view controller) as a "hub". But I want to say in C that I want to B. I'll set next target (doesn't matter how) and perform unwind from C to A which know where to go next, and in unwind target action it calls ther right performSegueWithIdentifier but nothing happens.

This was supposed to be an proof of concept and it would results in two animations. The target solution would be for user to transition the UI directly from the C to B.

Can anyone suggest some possible solutions?

Thanks.

Additional info: B and C are storyboard references.

Upvotes: 0

Views: 234

Answers (2)

Francois David
Francois David

Reputation: 1

You could use the function programatically:

self.present(viewControllerToPresent: UIViewController, animated: Bool, completion: (() -> Void)?) 

And call another segway in the completion block like so:

self.present(viewControllerToPresent: Ccontroller, animated: true){
       Ccontroller.present(viewControllerToPresent: Bcontroller, animated: true, completion: nil) 
} 

Upvotes: 0

ZGski
ZGski

Reputation: 2538

I would suggest considering the use of a UITabBarController. This would allow users to move freely between ViewControllers.

Each tab of a tab bar controller interface is associated with a custom view controller. When the user selects a specific tab, the tab bar controller displays the root view of the corresponding view controller, replacing any previous views.

Upvotes: 1

Related Questions