简体   繁体   English

自定义类,前缀未显示在Interface Builder的自定义类组合框中

[英]Custom class with prefix not showing up in custom class combo box in Interface Builder

If I create a custom class called MTViewController that is derived from UIViewController, I can't select it in the custom class combo box in Interface Builder in XCode 4.5. 如果我创建一个名为MTViewController的自定义类派生自UIViewController,我无法在XCode 4.5中的Interface Builder中的自定义类组合框中选择它。 Anybody know why? 谁知道为什么?

I think it's a bug of Interface builder. 我认为这是Interface builder的一个错误。 And also it's not related with UIViewController or MTViewController. 而且它与UIViewController或MTViewController无关。 For some reason it doesn't show some of the newly added class names over there but if you type it yourself and run the application you don't get any errors. 由于某种原因,它没有在那里显示一些新添加的类名,但如果您自己键入并运行应用程序,则不会出现任何错误。

Moreover you can try this, after creating a class just close the project and open it again . 此外,您可以尝试这个,在创建一个类之后关闭项目并再次打开它。 If you go to identitiy inspector this time you will see the class name there. 如果你这次去识别检查员,你会看到那里的班级名称。 SO in my opinion it is a bug in XCode. 所以我认为这是XCode中的一个错误。

Thanks 谢谢

you can try any of these steps. 你可以尝试任何这些步骤。

  1. Make sure it inherits UIViewController. 确保它继承了UIViewController。 @interface MTViewController : UIViewController @interface MTViewController:UIViewController
  2. Under target check in build phase if MTViewController.m is present 如果存在MTViewController.m,则在目标检查构建阶段
  3. Delete the UIViewController UI object and put it back again and check if its appears back in custom class 删除UIViewController UI对象并将其重新放回,并检查它是否显示在自定义类中

  4. Just to reset it close your project and open it back again. 只是重置它关闭你的项目并再次打开它。

Ok, I just upgraded my iMac and Macbook to Xcode 6.3. 好的,我刚刚将iMac和Macbook升级到Xcode 6.3。 On my iMac everything was rosey with my project but on my Macbook I could not get any of my custom view controllers to appear in the custom class field of the file owner of any of my xibs. 在我的iMac上,我的项目一切都很好,但在我的Macbook上,我无法将任何自定义视图控制器显示在我的任何xib文件所有者的自定义类字段中。 Even creating a new project still wouldn't work. 即使创建一个新项目仍然行不通。 I knew it wasn't a problem with my project because it worked on my iMac. 我知道这不是我的项目的问题,因为它适用于我的iMac。

So after hours of trying different solutions and tweaks the only thing that worked was uninstalling Xcode 6.3 and re-installing it. 因此,经过几个小时的尝试不同的解决方案和调整,唯一有用的是卸载Xcode 6.3并重新安装它。 I believe this problem came out of the something getting out of sync as I have upgraded through multiple versions of Xcode over the years. 我相信这个问题是由于我多年来通过多个版本的Xcode升级而导致的事情不同步。

Save yourself the headaches for anyone reading this and start with a clean version of Xcode if you get this problem. 如果你遇到这个问题,请为阅读此内容的人保留令人头痛的问题,并从干净版的Xcode开始。

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

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