In the Storyboard, select the view controller that you want to instantiate in code. Make sure the yellow circle is highlighted, and click on the Identity Inspector. Set the custom class as well as the field called "Storyboard ID". You can use the class name as the Storyboard ID.
Specifying the Initial View Controllerstoryboard and select the Tab Bar Controller Scene. On the right, select the Attribute inspector. You'll find a checkbox named Is Initial View Controller. Checking this box will identify the selected view controller as the initial entry point for the storyboard you're on.
To link the SwiftUI View to the Host Controller we need to use an IBSegueAction. First, open the storyboard, then change the editor to “Editor and Assistant” view (In the menu bar: Editor -> Editor and Assistant). This should bring up the TodayViewController class. This opens in a new window.
A view controller manages a single root view, which may itself contain any number of subviews. User interactions with that view hierarchy are handled by your view controller, which coordinates with other objects of your app as needed. Every app has at least one view controller whose content fills the main window.
Just for future reference:
I'm developing on iOS 6 using Storyboards.
I was having the same issue, but I could not find the "Identifier" field in the inspector. Instead, just set the field named "Storyboard ID" to what you would name the Identifier. This field can be found under the "Show the Identity inspector" tab in the inspector.
[Note - comments below indicate that some people have found that they need to (also?) set the field "Restoration ID" just below the Storyboard ID in the inspector. Clicking on "Use Storyboard ID" does not seem to be enough.]
There's an image below for reference: (in this instance I've named my identifier the same as my class)
In Xcode 7 - 13,
when you change storyboard IDs and you get errors like this,
just CLEAN your project (CMD+SHIFT+K)
let storyboard = UIStoryboard(name: "StoryboardFileName", bundle: nil)
let controller = storyboard.instantiateViewController(withIdentifier: "StoryboardID")
self.present(controller, animated: true, completion: nil)
Note:
"StoryboardFileName"
is the filename of the Storyboard and not the ID of the storyboard!"StoryboardID"
is the ID you have manually set in the identity inspector for that storyboard (see screenshot below). Sometimes people believe that the first one is the Storyboard ID and the second one the View Controller class name, so note the difference.
Fixed! Not only the identifier in the segue must be set, in my case DrivingDetails, but also the identifier in my tableViewController must be set as DrivingDetails...check my picture:
I also removed the navigation view controller so now the 2 table view controllers are connected directly with a "push" animation.
*****EDIT for XCODE 7.0*****
you have to set the storyboardId(in this case the viewController is embedded in a Navigation controller:
let lastMinVc = mainStoryBoard.instantiateViewControllerWithIdentifier("lastMinuteNavController") as! UINavigationController
Identity located in Identity Inspector tab named Storyboard ID for Xcode 6.3.2 and checked Use Storyboard ID option.
Just had this issue after adding a new VC to the storyboard but only on the device, not on the simulator. Turns out it was due to having multiple storyboard localizations - the VC was only added to the primary one. I tried removing the other localizations (one of which is the one my iPhone uses) but still had the error. In the end I had to recreate the other localizations with the new VC in each of them.
Compiler shows following error :
Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: 'Storyboard (<UIStoryboard: 0x7fedf2d5c9a0>) doesn't contain a
ViewController with identifier 'SBAddEmployeeVC''
Here the object of the storyboard created is not the main storyboard which contains our ViewControllers. As storyboard file on which we work is named as Main.storyboard. So we need to have reference of object of the Main.storyboard.
Use following code for that :
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];
Here storyboardWithName
is the name of the storyboard file we are working with and bundle
specifies the bundle in which our storyboard is (i.e. mainBundle
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With