Defining a “generic” segue in Interface Builder

2020-08-11 10:50发布

问题:

I understand how to create a segue in XCode 4.2 by right clicking a control, let's say a button, and dragging it to a view controller in the storyboard.

What I would like to do is create a segue that is not tied to a control, and must be invoked programmatically so I can do something like this:

- (void)viewDidLoad
{
    if (condition) 
    {
        [self performSegueWithIdentifier: @"identifier" sender: self];
    }
}

while still defining the "identifier" segue within Interface Builder. Is this possible?

回答1:

You can ctrl-drag from the source view controller to the other scene. You can use the view controller object at the bottom of the scene to do this.

Then of course give it the appropriate identifier and then your code above should work fine.

Hope that helps.