Search code examples
iosxcodeuitableviewuiviewcontrollerpushviewcontroller

how to push UIViewController from UITableView


So basically, how can I push a UIViewController from a UITableView. I have an array of contents on the TableView I need to tap inside the content and get the ViewController as result. I tried making a - (IBAction)PushViewController:(id)sender but I can't reference the TableView.

Yes, i'm noob... ):


Solution

  • If you set a UITableViewDelegate for your table view, tableView:didSelectRowAtIndexPath: will get called when someone taps on a cell. At that point you can push another controller, optionally telling it what to display.