Instantiateviewcontrollerwithidentifier - Storyboard Id Set But Still Not Working

storyboard instantiateViewControllerWithIdentifier not setting IBOutlets

The view seems to be initialized properly only after it is accessed first. The problem goes away when calling

[self presentViewController:vc animated:NO completion:nil];

or more simply

[vc view];

Storyboard doesn't contain a view controller with identifier

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:

Sample Image

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

Sample Image

Setting View Controller Storyboard ID Doesn't Work

I had the same problem. I just clean the project and delete the app from my simulator or phone and run it again. It worked.

Instantiate and Present a viewController in Swift

This answer was last revised for Swift 5.4 and iOS 14.5 SDK.


It's all a matter of new syntax and slightly revised APIs. The underlying functionality of UIKit hasn't changed. This is true for a vast majority of iOS SDK frameworks.

let storyboard = UIStoryboard(name: "myStoryboardName", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: "myVCID")
self.present(vc, animated: true)

Make sure to set myVCID inside the storyboard, under "Storyboard ID."

STORYBOARD EXCEPTION - Storyboard doesn't contain a view controller with identifier

I figured it out, the problem was that the Storyboard wasn't updating in the device.

  1. Uninstall the app from the simulator/iPhone/iPad
  2. Product > Clean
  3. Build & Run

As stated in @T0m_Twt's answer in this question

where to get identifier for instantiateViewControllerWithIdentifier

You need to use a StoryBoard ID.

You can give it in storyboard as in image shown.

storyboard ID

Then use this id as

SomeController *myController =  [self.storyboard 
instantiateViewControllerWithIdentifier:@"ViewController"];

instantiate ViewController With storyboard Identifier in IOS

The problem here is that you are referencing outlets that haven't yet been created. I would try adding the User model as a property of the view controller (or use some sort of intermediate controller for this), setting the user property in your function above, then in viewDidAppear set the text of all the controls appropriately using the User model.

If you do this on the viewDidAppear function you can be certain all of your views have been instantiated. this is also better design, after all; why does your LoginViewController class need to know about the internals of profileViewController? Encapsulating logic in this way will lead to less problems down the line.

Hope this helps.



Related Topics



Leave a reply



Submit