How to connect ViewController.swift to ViewController in Storyboard?
- Choose your ViewController in the storyboard or scene list (mine is called
Circuit
). - Click on the
Identity Inspector
on the right - Select
Custom Class > Class > Type name of your swift file
.
DONE :)
How to link storyboard to view controller
I fixed the problem.
I modified call method.
let storyBoard : UIStoryboard = UIStoryboard(name: "ChatViewController", bundle:nil)
let chatViewController = storyBoard.instantiateViewController(withIdentifier: "ChatViewController")
self.navigationController?.pushViewController(chatViewController, animated: true)
Thank you for your kindness advice.
How to connect storyboard to viewcontroller
Unless I'm misunderstanding what you're asking, it's still there. Here are the steps to assign a custom view controller class to your view controller:
- Choose your view controller in the list of scenes on the left side.
- Choose the Identify Inspector on the right side.
- Choose the custom view controller class from the Class list.
Main.storyboard not connecting to viewcontroller.swift
Here is a quick guide for how to properly add a new View Controller.
Create a new ViewController.swift using the keyboard command
cmd
+n
. Choose the Cocoa Touch ClassName it whatever you want & make sure it's a subclass of
UIViewController
Create and save the new .swift file. Now, copy the name of your view controller.
In your storyboard, create a new view controller and select it.
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
Hope that helps :)
Trouble Linking Newly Created View to View Controller Class in Storyboard
To connect your ViewController.swift
files to the ViewController
s, do the following:
- Select the
ViewController
in Storyboard. - Navigate to the Identity inspector on the right panel.
- In the field Class, select the dropdown arrow.
- Select your
ViewController.swift
file that you would like to link to theViewController
in Storyboard.
This is a very easy step to miss. I've done it myself many times before. For future reference, when creating a new ViewController
in Storyboard, connect it to its ViewController.swift
file as soon as possible. Otherwise, it may result in incorrect Interface Builder connections, etc.
Adding Multiple View Controllers to ViewController.swift From Storyboard UI
If I understand correctly, you have multiple view controllers all with the same class "ViewController" that you want to duplicate and edit all the same way? You have to label each class differently or else the system crashes its like having twins and naming them all the same name and getting confused why they dont know which one you are talking to.
Related Topics
"Too Many Symbol Files" After Successfully Submitting My Apps
Run iPhone as an Ibeacon in the Background
How to Invoke iPhone Maps for Directions with Current Location as Start Address
Is There Any Way of Asking an iOS View Which of Its Children Has First Responder Status
Uifont - How to Get System Thin Font
iOS - Ensure Execution on Main Thread
Wkwebview and Nsurlprotocol Not Working
iPhone Uitableview. How Do Turn on the Single Letter Alphabetical List Like the Music App
Are Headphones Plugged In? iOS7
How to Check Version of a Cocoapods Framework
Presenting Viewcontroller with Navigationviewcontroller Swift
Arkit Hide Objects Behind Walls
Uicollectionview Insert Cells Above Maintaining Position (Like Messages.App)
Changing Tab Bar Item Image and Text Color iOS
Expanding and Collapsing Uitableviewcells with Datepicker
How to Set Mime Type of Application/Vnd.Apple.Pkpass in Order to Share Pass by Link or Email
Two iOS Apps Using the Same Facebook App Id - Is It Possible
Conditionally Import a Framework (Such as Speech) Based on iOS Version in Swift