xcode 为什么新类不会出现在 Interface Builder 的 Identity Inspector/Custom Class 中?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13809567/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 02:17:23  来源:igfitidea点击:

Why won't new class show up in Identity Inspector/Custom Class in Interface Builder?

xcodeinterface-builder

提问by pdenlinger

I'm having a repeating problem in Xcode 4.5 and would like to ask for help/advice.

我在 Xcode 4.5 中遇到重复问题,想寻求帮助/建议。

Have been creating a new class, BIDSwitchViewController, which is a subclass of UIViewController. When I go to the Identity Inspector to layout the .xib file, of course I want to change the class it belongs to to BIDSwitchViewController, so that I can layout my objects and make my connections.

一直在创建一个新类,BIDSwitchViewController,它是 UIViewController 的子类。当我去 Identity Inspector 布局 .xib 文件时,当然我想将它所属的类更改为 BIDSwitchViewController,以便我可以布局我的对象并建立我的连接。

But BIDSwitchViewController doesn't show up in the dropdown list for Custom Class in Identity Inspector. So then I hardcode "BIDSwitchViewController" into the text box, but then that doesn't stick.

但是 BIDSwitchViewController 没有显示在 Identity Inspector 中自定义类的下拉列表中。然后我将“BIDSwitchViewController”硬编码到文本框中,但这并没有坚持。

What am I doing wrong,and what can I do to fix this?

我做错了什么,我能做些什么来解决这个问题?

Thanks in advance.

提前致谢。

回答by sunkehappy

My way to solve this problem is to restart my Xcode! Then all works fine. Just have a try!

我解决这个问题的方法是重新启动我的Xcode!然后一切正常。试试吧!

回答by Sakiboy

If restarting doesn't fix it...

如果重启不能解决...

  1. Click on a different file
  2. then go back to your .Storyboardor .XIB.
  1. 单击不同的文件
  2. 然后回到你的.Storyboardor .XIB

...Or try and open up your .Storyboardor .XIBin a new tab. Basically you just want to force the IBto reload and re-render.

...或者尝试在新标签页中打开您的.Storyboard.XIB。基本上你只想强制IB重新加载和重新渲染。

回答by Sandeep Singh

Make sure you have selected "File Owner" in Placeholder before selecting the class.

在选择类之前,请确保在占位符中选择了“文件所有者”。

回答by Hos Mercury

After two days of frustrations and deleting the project then the Xcode itself, i did not find any solution until i remembered the inheritance of my viewController , it was a viewController for a table storyboard view, but it does inherit from a UIViewController not a UITableViewController . just when i corrected , it show up .

经过两天的挫折和删除项目然后是 Xcode 本身,我没有找到任何解决方案,直到我记得我的 viewController 的继承,它是一个表故事板视图的 viewController,但它确实从 UIViewController 继承而不是 UITableViewController 。就在我纠正时,它出现了。

Just make sure that your view has the right inheritance class as the same storyboard view .

只需确保您的视图与相同的故事板视图具有正确的继承类。

class AddItemViewController: UITableViewController

回答by ChansonYan

It is the problem of Xcode, you should switch between selecting table view and table view controller (File's owner in your practice), and the new added file names will pop out in the drop down list. I have tried, and it's done.

是Xcode的问题,你应该在选择table view和table view controller(你实践中的File's owner)之间切换,下拉列表中会弹出新添加的文件名。我试过了,已经完成了。

回答by physicsfrac

I have been struggling with this same problem as well and as Chanson Yan said click on table view or any view, then click on the main view controller (File's Owner) then check the drop-down menu again and it should appear.

我也一直在为同样的问题苦苦挣扎,正如 Chanson Yan 所说,单击表视图或任何视图,然后单击主视图控制器(文件的所有者),然后再次检查下拉菜单,它应该会出现。

回答by elia

SpecialViewController.hand SpecialViewController.mmay be looking as a C - file and C - header file.

SpecialViewController.hSpecialViewController.m可能看起来像是 C 文件和 C 头文件。

I tried , right click on SpecialViewController.hthen Show File Inspector.

我试过,右键单击SpecialViewController.h然后显示文件检查器

Then switched the Typeto Objective-C sourcefrom the C-source, then it worked for me.

然后将TypeC-source切换到Objective-C,然后它对我有用。