Nib but did not get a UITableView

My application works for iOS 5.1, but for the iOS 6 sim, the following error appears.

Application termination due to an uncaught exception 'NSInternalInconsistencyException', reason: '- [UITableViewController loadView] loaded the tip of' MainListViewController 'but did not receive a UITableView.

I am subclassing the UITableViewController and I don't want to change it.

The table structure is created programmatically, for loading from Mainwindow.xib Tab Bar Controller there is a dummy MainListViewController.xib .

I also tried to remove MainListViewController.xib , remove it from Mainwindow.xib Tab Bar Controller, created MainListViewController in AppDelegate and added it to Control Bar Controller as UITabBarItem to get rid of this problem with nib, but I still get the same error.

+54
ios ios6
Jun 27 '12 at 8:01
source share
13 answers

If you have a NIB for a subclass of UITableViewController , then its view output must be connected to a UITableView .

You are right to remove MainListViewController.xib and do it all in the code, but the reason it did not work for you is that the old XIB will not be deleted during assembly and startup. So, uninstall the application from the simulator and try again. He should work then.

+91
Jun 27 '12 at 8:28
source share

I had a similar problem using storyboards. I will send my decision for the benefit of others. The key is that if you correctly set the owner of the file to a subclass of UITableView, you still need to make sure that the view property is set to the table view. I use storyboards, but the same goes for knives. Expand the "outline of the document" so you can see the hierarchy of your storyboard. I will include some screenshots below. A quick way to solve this problem is that you want to see your opinion in the outline of the document. Delete any kind of table that you have as a child. Drag another table view over the view property. Done. I will show you screenshots.

enter image description here

Pay attention to two tables. You want to delete table1 and its cell.

enter image description here

Good. Now drag table2 into the view and you're done. Should work now. Basically, if you have a subclass of UITableViewController, then it should look like a table instead of a view or it will fail.

enter image description here

+27
Oct 07 '13 at
source share

The reason may be:

.h check that it is a subclass of UIViewController. this will solve the problem.

+16
May 31 '13 at 11:00
source share

In short, you are setting up a subclass of UITableViewController for UIViewController !! You can not do it. You must give the UIViewController a subclass of UIViewController.

+9
02 Sep '14 at 15:20
source share

I find a solution when using Storyboards and 1 Table View.

The key is to create a custom class (newViewController) just to test the subclass of UITableViewController. After creation Go to the table view controller (our table) and in the Identity Inspector select the custom class that has just been created (newViewController).

This works for me. Hope my comment helps someone.

+4
Jan 29 '14 at 5:47
source share

There are several reasons why this could happen.

  • You may not have added UITableViewDelegate and UITableViewDataSource for your .h

    @interface TableController: UIViewController {

  • You may not have connected your declared outputs to components in the storyboard / Nib

  • Perhaps you are calling a UIViewController instead of a UITableView or a video game in your .h

@interface TableController : UIViewController

or

  @interface TableController : UITableViewController 
+3
Nov 07 '13 at 2:30
source share

Please connect the table view as View outlet.outlet must be connected to the UITableView.

+3
Dec 02 '13 at
source share

If you use UITableView as your top view.

Like this:

enter image description here

You need to use UITableViewController in your controller

 class ItemsViewController: UITableViewController 

If you are using a UITableView under the view in your Storyboatd.

Like this:

enter image description here

You need to use UITableViewDelegate and UITableViewDataSource with UIViewController

 class ItemsViewController: UIViewController, UITableViewDelegate, UITableViewDataSource 
+3
Jun 25 '17 at 23:38 on
source share

I had this problem and the solution was just one simple task.

Hold the tip if you have already created ...

Go to (XIB file) and add the tableView component from the object library to the screen of the iPhone XIB file, and it should work :)

+1
Dec 25 '12 at 20:14
source share

It worked for me. Hope this helps you.

In AppDelegate →

 #import "TableViewController.h" // name of your TableViewController class - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { //PUT TableViewController *controller = [[TableViewController alloc] initWithStyle:UITableViewStylePlain]; self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; self.window.rootViewController = controller; self.window.backgroundColor = [UIColor whiteColor]; [self.window makeKeyAndVisible]; // Override point for customization after application launch. return YES; } 

Make sure your storyboard points to this class in the storyboard:

Story board

0
Sep 04 '14 at 4:15
source share

I also ran into this problem, but I used the storyboard in xcode 6.2. I removed the corresponding view from the storyboard and dragged the table view controller from the object library to the storyboard, then it works.

0
Apr 30 '15 at 2:19
source share

@smileBot's answer helped me understand that the solution is very simple, and the error caused by iOS makes sense

Application termination due to an uncaught exception 'NSInternalInconsistencyException', reason: '- [UITableViewController loadView] loaded the tip of' MainListViewController 'but did not receive a UITableView.

Basically they say that the nib view controller does not return a UITableView because it is not, for most - your nib returns a View - which is created for you by default when you create a new ViewController in Xcode.

The solution is as simple as deleting the View , which can be compared to the norm, but select it and click "Back" and then drag the UITableView inside your ViewController, and this UITableView will now act as the root view inside your TableViewController.

Keep in mind that this is only necessary for classes directly subclassing the UITableViewController.

Good luck.

0
Aug 18 '15 at 5:56
source share

I have the same problem, and after spending 3 hours I will find out ... "this is a mistake." I use the tableviewcontroller class and give a reference to the uiviewcontroller of this class, instead of the class controller class, I take the tableviewcontroller class when I take the uiviewcontroller into storyboards. therefore, remove the tableviewcontroller class and insert your tableviewcontroller class code to view the controller class, "do not paste all the code, just insert the logic", after that, in the storyboard in the identification inspector, give a link to the class of the current controller class of the view.

0
Aug 11 '16 at 18:20
source share



All Articles