Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SWRevealViewController nib cell not performing segue

Simply put, I have a slide navigation view controller in my app with a back table VC and a front table VC. A selected cell in the back table VC is supposed to segue to the front table VC (embedded in a navigation VC). To illustrate, here are the isolated pre-change settings and code with it working properly:

enter image description here enter image description here enter image description here

Here is the simplified working code in my back table VC's cellForRowAtIndexPath method:

    override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let navigationCell = tableView.dequeueReusableCellWithIdentifier("NavigationCell", forIndexPath: indexPath) as UITableViewCell
    return navigationCell
}

Ok, onto the fun part. All I want is to replace the default UITableViewCell shown above with one of my custom cells in a Xib file. Now I'll illustrate what I modified. First, here's my Xib cell in my NavigationCell.xib file. Nothing special.

enter image description here enter image description here

My NavigationCell class code is simply

import UIKit

class NavigationCell: UITableViewCell {
    @IBOutlet var nameLabel: UILabel!
}

Finally, I modified my code in my back table VC to register the Xib and dequeue the custom cell:

override func viewDidLoad() {
    super.viewDidLoad()
    let navigationCellNib = UINib(nibName: "NavigationCell", bundle: nil)
    tableView.registerNib(navigationCellNib, forCellReuseIdentifier: "NavigationCell")
}

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let navigationCell = tableView.dequeueReusableCellWithIdentifier("NavigationCell", forIndexPath: indexPath) as! NavigationCell
    return navigationCell
}

All other code and specifications remain the same. The storyboard segue for the new custom cell is still from the class SWRevealViewControllerSeguePushController as shown in the first screenshot for this question. I simply swapped out the default UITableViewCell with my custom Xib cell.

This modification was enough to stop the segue from occurring. With this modification, after I build and run when I slide out the back table VC navigation menu and select one of my custom navigation cells (which display properly), it doesn't trigger any segue. Any thoughts?

like image 316
Aaron Avatar asked Nov 19 '15 21:11

Aaron


1 Answers

I'm an idiot. I had to perform the segue programmatically in didSelectRowAtIndexPath.

override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
    self.performSegueWithIdentifier("MySegue", sender: self)
}
like image 176
Aaron Avatar answered Oct 07 '22 14:10

Aaron