Oli Black
Oli Black

Reputation: 441

Segue to UIViewController from a xib

I have a custom UIView which is a xib file and then a class that controls this view. I also have a storyboard which a lot of different view controllers inside. How do I perform a segue from the UIView to a specific UIViewController that is inside the storyboard?

Thanks

Upvotes: 0

Views: 461

Answers (2)

Simon McLoughlin
Simon McLoughlin

Reputation: 8465

You can't do that. What you can do is give the UIViewController a storyboard ID, using the menu on the right of the interface builder.

enter image description here

Then call it programatically, like so:

MyCustomViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"MyViewController"];

[self.navigationController pushViewController:vc animated:YES];

Upvotes: 1

TAKeanice
TAKeanice

Reputation: 521

You could put a ViewController into the Storyboard, set the class to your custom ViewController. Then, if you have class files for the view in the xib, set your custom view as the VC's view (already saves some code in loadView) and then just add a segue from the custom VC to the other view controller. To trigger that segue, you have to call [self performSegueWithIdentifier:@"identifierOfSegue"] in your custom ViewController.

Upvotes: 0

Related Questions