I have a segue (called "ToSettingsSegue") that pushes a custom view controller (SettingsTableViewController) onto a UINavigationController‘s stack. SettingsTableViewController has prototype cells ("prototypeSliderCell") set up. It goes without saying that this is setup in a storyboard.
Another section of code pushes SettingsTableViewController onto the UINavigationController‘s stack programmatically. In SettingTableViewController‘s -tableView:cellForRowAtIndexPath: method, -dequeueResusableCellWithIdentifier: returns nil when this is done programmatically.
I assume this occurs due to the prototype cells not being available programmatically.
My workaround? Calling -perfromeSegueWithIdentifier:sender: and sending "ToSettingsSegue" and self.
Is there a better solution to this problem? I cannot help but feel that this is dirty.
When you instantiate your SettingsTableViewController in code rather than through a storyboard segue the prototype cell definition is not available since it is only defined in your storyboard.
The “workaround” you describe should work fine, and I see nothing dirty about it. There are plenty of instances where you’ll want to programmatically trigger a storyboard segue to happen, and that’s what
performSegueWithIdentifier:sender:was designed to handle.