应用程序试图在目标上推送一个nil视图控制器

时间:2013-07-23 19:55:36

标签: ios uitableview push

我收到以下错误:

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

当我'点击'UITableViewController的单元格时会导致此错误。 代码:

#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 个答案:

答案 0 :(得分:21)

此错误表示您的ViewController未正确分配,我猜self.storyboard为零,如果是,则表示您没有初始化您的主viewController,您可以执行以下技巧:

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