简体   繁体   中英

Subclassing a UITableViewController without nib or storyboard?

I'm trying to subclass UITableViewController just with just code without a nib or storyboard. Upon loading its view I get this error:

'NSInternalInconsistencyException', reason: '-[UITableViewController loadView] loaded the "BYZ-38-tfr-view-1bC-Xs-vdC" nib but didn't get a UITableView.'

I've tried setting self.tableView with a new table view in :loadView but that doesn't fix it, nor does setting it in any initializers. Any solutions?

Edit : The class is a plain subclass of UITableViewController generated from the "new file" menu. No customizations have been made.

It may help to note that the project itself has a storyboard, and I'm loading the UITableViewController subclass by making the app's starting view controller to be the subclass.

The error is easily reproducible by creating a new single-view template project in Xcode, generating a plain UITableViewController subclass, and setting the only view controller in the storyboard to be of the UITableViewController subclass type.

Edit 2 : Problem solved, check comments.

I fixed it by avoiding any storyboard whatsoever. Originally I had it being loaded via the projects main storyboard. Instead, I now load up the subclass instance in a separate view controller, avoiding the error.

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