17

I have been going through this tutorial, "Option 2: Prototype Cells" I implimented all the steps, but, the following code gives me an error:

@interface MTViewController : UITableViewController

@end

the error message is:

instantiated view controller with identifier "UIViewController-BYZ-38-t0r" from storyboard "Main", but didn't get a UITableView.'

Here is what I tried - I changed UITableViewController to UIViewController and the error went away. But, the tableview remains blank. Can you tell me why this is ?

  • What do you mean blank? When you add a View Controller to your storyboard it's vanilla. You have to add the elements to it. – Bob Oct 2 '15 at 10:42
0

Actually you are using UIViewController not UITableViewController. Delete your default view controller and drag new TableViewController in your storyboard. Because your ViewController not having TableView, it's trying to load cells.

Simple solution is : Delete ViewController and add TableViewController

0

make sure the dataSource is set to self.

  • Can you be more precise, or even share some code that helps to understand your answer? – Nico Haase Jun 18 at 11:30
3

I met exactly the same issue as you. You're probably using a UIViewController instead of a UITableViewController in the storyboard.

NOTE: Only subclass a custom UITableViewController in the storyboard is not enough. You'll see the difference: difference between UIViewController and UITableViewController

So you have to drag out a UITableViewController from the library, then move all things(cells) to it. Don't forget to check bindings and auto layouts if broken.

And of course you cannot move the tableview to the root of UIViewController, it just doesn't work like that. =)

3

I've had this problem too. I created originally plain UIViewController then i decided to rather use UITableViewController. Problem is that i forgot to set storyboard ID on new controller, and change it to something else on the old controller, otherwise you will instantiate the old controller from storyboard and this problem will occur.

-2

You Must subclass UIViewController instead of UITableViewController

//This is how you should go about it

@interface MTViewController : UIViewController


@end
14

Try changing your super class to UIViewController or change the controller in your storyboard to TableView Controller

@interface MTViewController : UIViewController, UITableViewDataSource, UITableViewDelegate

@end
41

In your storyboard, you need to make the root view of your UITableViewController a UITableView.

Interface Builder Table View Controller

Interface Builder Custom Class

5

Drag a new instance of Table View Controller into your storyboard, copy the cells you created in your previous controller into the new one.

This error occurred probably because you used the default UIViewController created by XCode which isn't a UITableViewController.

  • very subtle problem and obvious solution (assuming you appreciate the problem). now, why are my cell properties coming back NIL? – mobibob Aug 22 '17 at 20:26
  • this is wierd but it's true. Had the same problem, solved like you described – pulp Aug 24 '17 at 20:46

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.