I have a navigation controller, a view controller, and a table view that were all created in my storyboard:
When you touch a certain row in the table view, it SHOULD push a new controller onto the navigation controller, but instead nothing happens. Here is the code:
- (void) tableView: (UITableView *) tableView didSelectRowAtIndexPath: (NSIndexPath *) indexPath {
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle: nil];
UINavigationController *controller = (UINavigationController*)[mainStoryboard
instantiateViewControllerWithIdentifier: @"dbNav"];
SubLevelViewController *slController = [[SubLevelViewController alloc] initWithStyle:UITableViewStylePlain];
[controller pushViewController: slController animated: YES];
}
Try
- (void) tableView: (UITableView *) tableView didSelectRowAtIndexPath: (NSIndexPath *) indexPath {
UINavigationController *controller = self.navigationController;
SubLevelViewController *slController = [[SubLevelViewController alloc] initWithStyle:UITableViewStylePlain];
[controller pushViewController: slController animated: YES];
}
Basically instantiateViewControllerWithIdentifier
creates a new instance of the specified view controller each time you call it, so you are pushing the view in a different Navigation controller than the one that is displayed