简体   繁体   中英

Why do I get this error when trying to use presentViewController?

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UITableViewController loadView] loaded the "2Pv-MD-gdY-view-bDF-TR-G6E" nib but didn't get a UITableView.'

Why am I getting that? The gist of my app is that I have a UITableViewController with a button that triggers an action sheet. The action sheet, when a specific option is pressed, then presents a view controller (modally). Here's my code:

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
    NSString *buttonTitle = [actionSheet buttonTitleAtIndex:buttonIndex];

    if ([buttonTitle isEqualToString:@"Text"]) {
        AddTextViewController *addTextViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"addTextViewController"];
        [self presentViewController:addTextViewController animated:YES completion:nil];
    }

}

I can supply any further needed information, but I'm not sure what's going wrong.

Did you create a view in a xib for this table view controller? You probably just need to connect the tableView property in the xib file to a tableView.

It looks like you're trying to instantiate a nib and it isn't present. Is the nib included as a project member?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM