Cannot select Custom Class for Table View Controller (UITableViewController)

眉间皱痕 提交于 2019-12-23 17:33:40

问题


Let me preface this by saying that I've already tried quitting and restarting Xcode, as well as deleting derived data for the project, to no avail. I'm at wits end right now.

Basically, I've created a custom ViewController class I want to use, but I cannot select it. In fact, using the Custom Class dropdown, I can only select the default UITableViewController class for my controller. The weird part is, it looks like the full list appears for a split second sometimes, before being replaced by the incorrect list with a single option. Here's what it looks like:

I would really appreciate any ideas here. I'm not really sure what I could have done wrong, since I was following this Apple tutorial pretty much to the T.

For another scene in my project, which is just a plain view controller, I can select custom classes with no problems.

Ideas?


回答1:


You have to inherit from UITableViewController class so basically the interface file (.h) should looks like that:

@interface YOURCLASSNAME : UITableViewController

Make sure you replace YOURCLASSNAME with your class name and you add UITableViewController and that should do the job.




回答2:


Make sure the swift file is defined as a UITableViewController and not as a UIViewController.



来源:https://stackoverflow.com/questions/22563298/cannot-select-custom-class-for-table-view-controller-uitableviewcontroller

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