Adding swift file to new view controller in xCode? (easy)

こ雲淡風輕ζ 提交于 2019-11-27 01:16:18

问题


I'm just starting out in xCode 6, and I can't seem to figure out how to add a new swift-file to the new view controllers I add in the interface builder.

Any tips on how to proceed would be appreciated.


回答1:


  1. Add a new Cocoa Touch class. Choose File->New->File... from the menu. Give this new class a name such as "ViewController2" and set the Subclass of: pop down to UIViewController. The file "ViewController2.swift" will be created.

  1. Click on your new View Controller in Interface Builder. In the Identity Inspector (on the right in Xcode) set the Custom Class for the View Controller to "ViewController2".




回答2:


If your custom class isn't showing up in the Identity Inspector, your files may have been moved or saved in the wrong folder. I would delete them from your project and try again, this time letting the files be saved wherever they are automatically. Good luck!



来源:https://stackoverflow.com/questions/26962713/adding-swift-file-to-new-view-controller-in-xcode-easy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!