Objective-J Objective-J - 4 months ago 19
Objective-C Question

How to use Storyboards with multiple segues to one view controller?

My app will use a simple login type selcector view controller, and from that it'll branch out to different view controllers, i.e. Sign Up, Sign In, and Sign In with Social networks. Now how do I add a segue from all of these to one single destination view controller. How do I add these multiple segues.

Answer

Every ViewController should have their own seque. To create, press "Ctrl" and move to the ViewController you want

enter image description here

And every ViewController should implement "prepareForSegue"

- (void)prepareForSegue:(UIStoryboardPopoverSegue *)segue sender:(id)sender {
    if ([segue.destinationViewController isKindOfClass:[MyDestinationVC class]]) {
        //do something
        //Example
        MyDestinationVC *screen = (MyDestinationVC *)segue.destinationViewController;
        screen.someValue = self.sendedValue;
    }
}
Comments