Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I create storyboard segue from a view controller to itself?

Is it possible to create a storyboard segue from a view controller to itself? I have a bunch of Entities that have Related Entities. I'd like to be able to display a Related Entity using the same view controller that's displaying the Entity. But I can't seem to create a segue that will display a new instance of the origin view controller.

Is it just not allowed? Thanks!

like image 837
CharlieMezak Avatar asked Nov 16 '11 17:11

CharlieMezak


People also ask

How do I create a segue between view controllers?

To create a segue between view controllers in the same storyboard file, Control-click an appropriate element in the first view controller and drag to the target view controller. The starting point of a segue must be a view or object with a defined action, such as a control, bar button item, or gesture recognizer.

How do I add a view controller to my storyboard?

Open Main. storyboard and select the Tab Bar Controller Scene. On the right, select the Attribute inspector. You'll find a checkbox named Is Initial View Controller.

How do I embed a view controller in navigation controller storyboard?

Step 1: Embed root view controller inside a navigation controller. In your storyboard, select the initial view controller in your hierarchy. With this view controller selected, choose the menu item Editor -> Embed In -> Navigation Controller .


2 Answers

Well here's a solution that isn't quite the same but gets me what I want. I found it as an answer to this question.

The reason I thought I had to use a segue rather than the good old programmatic push of a view controller onto the navigation controller's stack is that I had set up the view controller's IBOutlets in the storyboard. I didn't realize that you could create a copy of the view controller as laid out in the storyboard without using a storyboard segue. You can! To see how to do it, check out that other question and up vote the answerer!

like image 157
CharlieMezak Avatar answered Oct 04 '22 03:10

CharlieMezak


You can ctrl-click-drag (or right-click-drag) from an element (UIButton, etc.) to the containing view controller.

(Did you try this? I'm doing it right now; I have one stock UIViewController that just keeps adding itself indefinitely to the containing UINavigationController stack via a normal push segue.)

like image 32
Ben Mosher Avatar answered Oct 04 '22 04:10

Ben Mosher