zenProgrammer79
zenProgrammer79

Reputation: 31

Main.storyboard not connecting to viewcontroller.swift

I have kinda big problem: When I add a view controller to my main.storyboard and then try to hook it up to viewcontroller.swift it won't connect, but my original one does how do I fix this?

Upvotes: 0

Views: 3678

Answers (2)

LinusG.
LinusG.

Reputation: 28922

Here is a quick guide for how to properly add a new View Controller.

  1. Create a new ViewController.swift using the keyboard command cmd+n. Choose the Cocoa Touch Class
    step 1

  2. Name it whatever you want & make sure it's a subclass of UIViewController
    step 2

  3. Create and save the new .swift file. Now, copy the name of your view controller.
    step 3

  4. In your storyboard, create a new view controller and select it.
    step 4

  5. On the right hand side, under Custom Class, insert the new view controller's name (you should have copied that, so just hit paste) and hit enter
    enter image description here

Hope that helps :)

Upvotes: 1

TParizek
TParizek

Reputation: 580

Each View Controller in story board should have it`s own subclass of UIViewController. You can create new by pressing cmd + n -> Cocoa Class -> Subclass of "UIViewController".

Upvotes: 0

Related Questions