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:
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
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.
- Uninstall the app from the simulator/iPhone/iPad
- Product > Clean
- 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.
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
Drawing a Polygon with One Color for Stroke, and a Different One for Fill
Property 'Self.*' Not Initialized at Super.Init Call
Uiwebview Not Go to Didfailloadwitherror When Weblink Not Found
How to Show Specific Language Keyboard When User Input Values in Uitextfield in iPhone App
Programmatically Detect Dark Mode in Swiftui to Display Appropriate Image
Download PDF and Save to the "Files" in Iphone, Not to the App Data, Swift
Add Button at the End of Collection View in Storyboard
How to Tell If an iOS Device Has a Gps
Is This a Bug with Mkmapkitdelegate Mapview:Didupdateuserlocation
How to Code the Launchscreen Programmatically
Detecting When App Is Becoming Active from Lockscreen VS Other on iOS7
Autolayout Ignores Multi-Line Detailtextlabel When Calculating Uitableviewcell Height (All Styles)
Swift, Dispatch_Group_Wait Not Waiting
How to Use Avcapturephotooutput to Capture Photo Swift + Xcode