Storyboard “Main”, but didn't get a UITableView when using UITableViewController

穿精又带淫゛_ 提交于 2019-12-03 01:27:25

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

Bob

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

@interface MTViewController : UIViewController, UITableViewDataSource, UITableViewDelegate

@end

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.

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. =)

luky

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.

iOS

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, but it's trying to load cells.

Simple solution is : Delete ViewController and add TableViewController

Then you have to change its class name to MTViewController or Your Class Name

make sure the dataSource is set to self.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!