将swift文件添加到xCode中的新视图控制器? (简单)

时间:2014-11-16 22:18:37

标签: swift xcode6 viewcontroller

我刚刚开始使用xCode 6,我似乎无法弄清楚如何将新的swift文件添加到我在界面构建器中添加的新视图控制器中。

有关如何继续的任何提示将不胜感激。

2 个答案:

答案 0 :(得分:60)

  1. 添加一个新的Cocoa Touch类。从菜单中选择文件 - >新建>文件... 。为这个新类命名,例如" ViewController2"并将子类:弹出到 UIViewController 。文件" ViewController2.swift"将被创建。
  2. enter image description here

    enter image description here

    1. 在Interface Builder中单击新的View Controller。在 Identity Inspector (Xcode右侧)中,将View Controller的自定义类设置为" ViewController2"。enter image description here

答案 1 :(得分:0)

如果您的自定义类未显示在Identity Inspector中,则您的文件可能已被移动或保存在错误的文件夹中。我会从你的项目中删除它们并再试一次,这次让文件自动保存在任何地方。祝你好运!