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:
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.
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?
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)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With