简体   繁体   English

Xcode 5无法识别故事板中的自定义UIViewController子类

[英]Xcode 5 does not recognize custom UIViewController subclass in storyboard

I have a storyboard app in Xcode 5 with many custom view controllers and segues and everything works well, except in one case. 我在Xcode 5中有一个故事板应用程序,有许多自定义视图控制器和segue,一切都很好,除了一个案例。 In this case, I have a "View Controller Scene" where I am trying to use a custom UIViewController subclass. 在这种情况下,我有一个“视图控制器场景”,我试图使用自定义UIViewController子类。 But even though I specify the subclass, the entry in the sidebar is still called "View Controller Scene" and the View Controller entry for that scene is shown as just the generic "View Controller" (where in every other case, the scene label is changes to reflect the subclass, as is the View Controller entry). 但即使我指定了子类,侧栏中的条目仍称为“视图控制器场景”,该场景的视图控制器条目仅显示为通用“视图控制器”(在其他情况下,场景标签为更改以反映子类,视图控制器条目也是如此。

So, Xcode does not appear to believe that I have specified a custom class for the View Controller for this scene. 因此,Xcode似乎并不相信我为此场景指定了View Controller的自定义类。 If it were only interface builder that was confused, that would be fine, but when I run the code, when I prepareForSegue: for the appropriate segue, the destinationViewController is a UIViewController, while I need it to be the custom subclass. 如果它只是混淆的界面构建器,那就没问题,但是当我运行代码时,当我准备ForSegue:对于适当的segue,destinationViewController是一个UIViewController,而我需要它作为自定义子类。

I know that my custom class must be a subclass of UIViewController, and it is (although several steps removed -- that is, it is a subclass of a subclass of a subclass of UIViewController). 我知道我的自定义类必须是UIViewController的子类,它是(虽然删除了几个步骤 - 也就是说,它是UIViewController的子类的子类的子类)。

The problem is not the Xcode 5 bug of not recognizing custom classes (the class name does show up in autocomplete for the Custom Class field) and Xcode has been restarted many times since this custom class was created. 问题不在于Xcode 5错误没有识别自定义类(类名称确实显示在自定义类字段的自动完成中),并且自创建此自定义类以来Xcode已重新启动多次。

So, what am I missing? 那么,我错过了什么? What could cause Xcode 5 not to recognize a custom class for a UIViewController? 什么可能导致Xcode 5无法识别UIViewController的自定义类?

Happens all the time, easiest way to solve it: quit Xcode and run it again. 一直发生,最简单的解决方法:退出Xcode并再次运行。 The view controller should now be visible. 视图控制器现在应该可见。

Its a thing that just happens sometimes, I usually ignore it, copy the name in and hit enter, but if its bothering you, you can try to clean and build your project, should start showing up then clean: cmd + shift + k build: cmd + b 它有时会发生,我通常会忽略它,复制名称并按Enter键,但如果它困扰你,你可以尝试清理并构建你的项目,应该开始显示然后清理: cmd + shift + k build : cmd + b

good luck! 祝好运!

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

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