简体   繁体   English

无法为表视图控制器(UITableViewController)选择自定义类

[英]Cannot select Custom Class for Table View Controller (UITableViewController)

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. 让我先说一下,我已经尝试过退出并重新启动Xcode,以及删除项目的派生数据,但无济于事。 I'm at wits end right now. 我现在正处于斗智斗勇的境地。

Basically, I've created a custom ViewController class I want to use, but I cannot select it. 基本上,我已经创建了一个我想要使用的自定义ViewController类,但我无法选择它。 In fact, using the Custom Class dropdown, I can only select the default UITableViewController class for my controller. 实际上,使用Custom Class下拉列表,我只能为我的控制器选择默认的UITableViewController类。 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: 这是它的样子:

尝试在Identity Inspector Interface Builder中选择我的类

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. 我不太确定我做错了什么,因为我几乎跟着这个Apple教程

For another scene in my project, which is just a plain view controller, I can select custom classes with no problems. 对于我的项目中的另一个场景,它只是一个普通的视图控制器,我可以选择没有问题的自定义类。

Ideas? 想法?

You have to inherit from UITableViewController class so basically the interface file (.h) should looks like that: 你必须从UITableViewController类继承,所以基本上接口文件(.h)应该是这样的:

@interface YOURCLASSNAME : UITableViewController

Make sure you replace YOURCLASSNAME with your class name and you add UITableViewController and that should do the job. 确保将YOURCLASSNAME替换为您的类名,并添加UITableViewController,这应该可以完成这项工作。

确保swift文件被定义为UITableViewController而不是UIViewController。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM