W. Schröder
W. Schröder

Reputation: 27

Create different segues from one tableView

I created a menu inside of my app.

The menu has 4 cells, which are created by modifying a prototype cell.

Each of those cells should perform a segue to one of 4 ViewControllers.

How can I realize this? Any ideas?

Upvotes: 0

Views: 120

Answers (1)

vacawama
vacawama

Reputation: 154721

You can either:

1) Create 4 prototype cells having each one wired directly to its respective viewController. In this case, each give each prototype cell its own identifier (for example "cell1", "cell2", "cell3" and "cell4") and then in cellForRowAtIndexPath dequeue using the appropriate identifier for the row: ["cell1", "cell2", "cell3", "cell4"][indexPath.row].

OR

2) Wire the segues from the viewController icon at the top of your viewController, give the segues identifiers, and trigger the appropriate segue with performSegueWithIdentifier in didSelectRowAtIndexPath.

wiring segue from VC

Upvotes: 3

Related Questions