问题
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