Bjarte Bjarte - 1 year ago 97
Swift Question

UITableViewCell segue to detail view when I load cell from nib?

I have a

custom cell class
and a
custom nib
that contains the design for that cell. In my
I don't see the way to connect the
as a
(Like you have with prototype cells) I have there since my cell is added via

Is there a way of getting this segue connected so I can continue to use the storyboard to connect cell to detail view controller?

Here is my code for

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell = tableView.dequeueReusableCellWithIdentifier("cell") as MyTableViewCell?

if (cell == nil) {
tableView.registerNib(UINib(nibName: "MyTableViewCell", bundle: NSBundle(identifier: "")), forCellReuseIdentifier: "cell")
cell = tableView.dequeueReusableCellWithIdentifier("cell") as MyTableViewCell?

return cell!

Answer Source

What I found out I could do, is to a add a manual segue (by dragging from controller) to the details controller (as Show segue with identifier: "showDetails"). Then I could add the following code on my table view:

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

Which would give me the functionality I wanted.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download