Loaded the "PersonnalDetails" tip but didn't get a UITableView

I am trying to load a new view using the following code

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

  PersonnelDetails *detailViewController = [[PersonnelDetails alloc] initWithNibName:@"PersonnelDetails" bundle:[NSBundle mainBundle]]; 

[self.navigationController pushViewController: detailViewController animated: YES]; [detailViewController release];

} Code> inheritance: - PersonnelDetails inherits the UITableViewController

but I get an exception: Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UITableViewController loadView] loaded the "PersonnalDetails" nib but didn't get a UITableView.' although I have a UITableView in the PersonnalDetails nib, and also I have connected the output representation of the PersonnelDetails (viewController) to the UITableView. what could be a positive reason?

+4
source share
4 answers

I don’t know what the problem is, but after restarting Xcode everything works fine.

+1
source

I think the problem is that you are subclassing the UITableViewController instead of the UIViewController. I used to have the same problem.

+14
source

This may seem odd, but in my case I really need a UITableViewController with a table view. I do not use xib files, so I build the whole interface using code.

I was getting the same error.

I did this to override the loadView method this way and it will work!

 - (void)loadView { [super loadView]; } 

What is now a stranger, if I comment on the loadView method, I get another error:

this class is not a key value compatible with the encoding for the key settings. View

and I do not use the settingsView property, and he commented.

Now I'm embarrassed! Although it works with overriding loadView.

Edit

I uninstalled the application from my iPhone and then ran it again using loadView and now it works ...

+5
source

You made a mistake in your .h file,

 @interface ViewController : UITableViewController<UITableViewDelegate, UITableViewDataSource 

or

 @interface SearchViewController : ViewController<UITableViewDelegate, UITableViewDataSource 

instead

 @interface SearchViewController : UIViewController<UITableViewDelegate, UITableViewDataSource 
+1
source

Source: https://habr.com/ru/post/1306862/


All Articles