Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

------- OBJECTIVE - C ------------- I added a Table View (as a SUBVIEW) on a Vie

ID: 3813326 • Letter: #

Question

------- OBJECTIVE - C -------------

I added a Table View (as a SUBVIEW) on a View Controller PROGRAMMATICALLY. It's NOT visible on the view controller in the storyboard.

When a user clicks on a cell in a table view, they should be taken to a different view controller.

You can switch view controllers through PerformSegueWithIdentifier But the code below is not working. When I click on the table view cell, nothing happens. I have a push segue.

HOW DO I SWITCH TO A DIFFERENT VIEW CONTROLLER PROGRAMMATICALLY?

pushing the view doesn't work either.

Explanation / Answer

To switch to a different view controller programmatically without using segue , the two steps are given as follows,

1. Set the identifier to the view , Enter your Identifier in the Storyboard ID

2. After setting the identifier create the destination and push the destination to the navigation controller .

Change the code with your appropriate storyboard name , view controller name and view controller id . It will open a new view controller by clicking on a cell in the table view.