EmperorPalpatine
EmperorPalpatine

Reputation: 55

simple segue from custom cell to view controller

I seem to not be getting a clear answer from researching previous questions. I have a table, and clicking on a cell does a push to another view controller. I did this by command+click from the prototype cell to the other view controller.

Now I have a custom cell which is not in the storyboard so I can't do the command+click to setup the segue!

Upvotes: 0

Views: 681

Answers (1)

Lucho
Lucho

Reputation: 1044

You should implement on your table view controller

override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
      self.performSegueWithIdentifier("showDetail", sender: self)
}

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.

    if segue.identifier == "showDetail" {
       //pass var to destination controller
    }

}

and on your storyboard connect both controllers with a segue and name it "showDetail"

hope it helps.

Upvotes: 2

Related Questions