[ad_1]
First wire a segue for each viewController. control-drag from the viewController icon at the top of
ViewControllerAto anotherViewControllerand select the segue type.
Click on the segue arrow between the viewControllers, and set its identifier in the Attributes Inspector on the right.
- Repeat steps 1 and 2 for each
ViewControllerB,ViewControllerCandViewControllerDgiving their segues unique id’s such as"segueToB","segueToC"and"segueToD". In your button code, do the following:
let idx = mySegment.selectedSegmentIndex let segueID = ["segueToB", "segueToC", "segueToD"][idx] self.performSegue(withIdentifier: segueID, sender: self)
Demo of connecting two segues:
6
[ad_2]
solved Different ViewController if different selectedSegmentIndex

