Question

For example, I want to create a button which will always push a simple view controller of the same class.

Of course I can place it in the same storyboard file with other view controllers. But it could be called from everywhere. So it means too many extra links in this storyboard.

Contrawise I didn't try to create another storyboard, not xib. But the view controller I need is so simple that the creating of a new storyboard for it looks like too extra.

Was it helpful?

Solution

You can invoke a view controller using an identifier instead of a unique identifier. Take a look a the method instantiateViewControllerWithIdentifier:

That enables you to create view controllers that "float" in your storyboard, without having segue links cluttering up the storyboard.

Once you've instantiated the view controller, you can then present it modally with presentViewController:animated:completion, push it onto a navigation controller, or whatever.

You can even instantiate a view controller with instantiateViewControllerWithIdentifier, then create your own segue object using initWithIdentifier:source:destination, and invoke that segue if you want to.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top