Pushing a navigation controller is not supported

Jose picture Jose · Jul 20, 2013 · Viewed 60.3k times · Source

In my MainStoryBoard I want to push a viewController to the detailView but I get this error:

NSInvalidArgumentException', reason: 'Pushing a navigation controller is not supported'

I set the identifier 'JSA' ID for the viewController on the storyboard.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0) {
        SWSJSAViewController *viewController = [[UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil] instantiateViewControllerWithIdentifier:@"JSA"];
        [self.navigationController pushViewController:viewController animated:YES];
    }
}

Answer

Tiago Almeida picture Tiago Almeida · Oct 30, 2014

Like rmaddy said in the comments you are trying to push a navigation controller.

Navigation controllers should be presented (via presentViewController or they can be added as a childViewController) and ViewControllers should be pushed.