无法在Xcode Storyboard中为ViewController选择自定义类 [英] Unable to select custom class for ViewControllers in Xcode Storyboard

查看:317
本文介绍了无法在Xcode Storyboard中为ViewController选择自定义类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚将Xcode升级到5.0。我对可可还很陌生,所以我希望可以忽略一些基本知识。基本上,我无法让Xcode看到要用作视图控制器父类的自定义类。最初,我想为tableview控制器创建一个自定义类,但是为了简化该问题,我尝试使用常规的viewcontrollers对其进行尝试,但这也不起作用。

I just upgraded Xcode to 5.0. I'm still fairly new to cocoa so I hope I'm overlooking something basic. Basically I can't get Xcode to see the custom classes that I want to use as parent classes for view controllers. Originally I wanted to create a custom class for a tableview controller but to simplify the problem I tried it with regular viewcontrollers, but that doesnt work either.

我的工作:


  • 创建新项目:单视图应用程序

  • 向其中添加可可类(File-> New -> File-> Objective-C类,我将其命名为MyViewController并使其成为UIViewController的子类

  • 我在情节提要中以及项目模板中选择项目模板随附的默认视图身份检查器,我尝试在自定义类下选择MyViewController

该类根本不会出现在下拉列表中,我自己也无法键入

The class simply does not appear in the drop down, and I cant type it myself either. Many other threats reporting the same problem suggest closing/reopening the project and Xcode but that doesnt work either for me.

推荐答案

当您在情节提要中,即Xcode的Interface Builder时,请确保单击视图下方的黑色条:

When you are in the storyboard, Interface Builder of Xcode, make sure you click on black colored bar under the view:

这将在情节提要中选择视图控制器(而非视图)。注意整个场景周围有一个蓝色边框。选择此项后,您可以在Identity Inspector中设置视图控制器的类。

This will select the view controller (not the view) in the storyboard. Notice how the whole scene has a blue border around it. Once this is selected, you can set the class of the view controller in the Identity Inspector.

这篇关于无法在Xcode Storyboard中为ViewController选择自定义类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆