Storyboard “Main”, but didn't get a UITableVie

2020-05-22 05:06发布

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 ?

8条回答
狗以群分
2楼-- · 2020-05-22 05:35

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.

查看更多
在下西门庆
3楼-- · 2020-05-22 05:35

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

查看更多
登录 后发表回答