crossboy007 crossboy007 - 1 year ago 100
Swift Question

How do I create a view controller file after creating a new view controller?

I am developing a tabbed application, but am having an issue very early on in its development.

My issue is that when I create a new view controller, and link it to the tab bar controller, unlike the other two view controllers that were made by default, this one has no


I was wondering if anyone knew how to create this file so I can actually code the GUI to do things?

I will also mention that I am on Xcode 6 and developing the app in swift.

Rob Rob
Answer Source

Correct, when you drag a view controller object onto your storyboard in order to create a new scene, it doesn't automatically make the new class for you, too.

Having added a new view controller scene to your storyboard, you then have to:

  1. Create a UIViewController subclass. For example, go to your target's folder in the project navigator panel on the left and then control-click and choose "New File...". Choose a "Cocoa Touch Class":

    Cocoa Touch Class

    And then select a unique name for the new view controller subclass:

    UIViewController subclass

  2. Specify this new subclass as the base class for the scene you just added to the storyboard.

    enter image description here

  3. Now hook up any IBOutlet and IBAction references for this new scene with the new view controller subclass.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download