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 ?
make sure the dataSource is set to self.
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.
In your storyboard, you need to make the root view of your
UITableViewController
aUITableView
.Try changing your super class to UIViewController or change the controller in your storyboard to TableView Controller
In the storyboard just change the class of your ViewController to your new class name which here is
MTViewController
- image of stepsI 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. =)