Application tried to push a nil view controller on target

狂风中的少年 提交于 2019-12-11 02:26:44

问题


I got the below error:

Application tried to push a nil view controller on target UINavigationController: 0x7b98940.

It is caused when I 'click' a cell of an UITableViewController. Code:

#pragma mark - Table view delegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    VerifyInfoViewController *verifyInfoVC = [self.storyboard instantiateViewControllerWithIdentifier:@"verifyInfoVC"];
    [self.navigationController pushViewController:verifyInfoVC animated:YES];
}

回答1:


This error means your ViewController has not been allocated properly, and i guess self.storyboard is nil, If yes this means you didn't initialise your master viewController and you can do the below trick:

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:[NSBundle mainBundle]];


来源:https://stackoverflow.com/questions/17819826/application-tried-to-push-a-nil-view-controller-on-target

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!