0

I'm having trouble with my didSelectRowAt portion of the code.

My menu (so far) has: Workout, Tips, Contact Us. They all have a special UIViewController dedicated to their view. In my didSelectRowAt func, I have a switch case:

UIViewController.swift

switch indexPath.row {
    case 0:
        // Call Workout View
        self.performSegue(withIdentifier: "wrkOut", sender: self)
    case 1:
        self.performSegue(withIdentifier: "tipsN", sender: self)

workoutView.swift

class workoutview: UIViewController {
override func viewDidLoad() { super.viewDidLoad()  }

Keeping in mind "wrkOut" is the title of the Workout view and not a push segue. When I try the code it just displays a black screen when clicked. I tried ctrl dragging a push segue to each view but it can only be directed to one of them.

How can I code this to go to a specific UIViewController when the row is clicked? We have to use push segues for whatever reason.

Yousuf
  • 1
  • 2
  • Yes, you have to create show segues between your table view controller (orange icon at the top of the scene) and each destination view controller and give each segue the appropriate identifier – Paulw11 Nov 17 '16 at 01:31
  • @Paulw11 Even when I do a show segue. It will only allow me to show one view on the storyboard – Yousuf Nov 17 '16 at 01:38
  • See my edit; you create the segue from the view controller, not the table cell. Then you can have any number of segues that you perform by identifier – Paulw11 Nov 17 '16 at 01:39
  • @Paulw11 Ahh ok. I get it now. I tried doing the push from the view itself instead of the icon. Thanks! – Yousuf Nov 17 '16 at 01:50
  • Please see how to use segue in statryboard .http://stackoverflow.com/a/21205550/1142743. don't forget to set workoutview as ViewController in stoaryboard for new View – Vinodh Nov 17 '16 at 05:04

0 Answers0