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

前端 未结 2 439
醉梦人生
醉梦人生 2020-12-08 14:48

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

相关标签:
2条回答
  • 2020-12-08 14:51
    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.

    enter image description here

    enter image description here

    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".enter image description here
    0 讨论(0)
  • 2020-12-08 14:58

    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!

    0 讨论(0)
提交回复
热议问题