Reputation: 1080
After capturing image, inside didFinishPickingMediaWithInfo
I'm trying to presentViewController
to another UIViewController
which has some buttons and labels already configured on the storyboard. But it is just showing up as blank.
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
let camVC = CamViewController()
if let image = info[UIImagePickerControllerOriginalImage] as? UIImage {
Albums.sharedInstance.chosenImage = image
picker.dismiss(animated: false, completion: nil)
present(camVC, animated: false, completion: nil)
}
}
I ran tests by printing stuff from the destination UIViewController
's viewDidLoad()
and am able to see the test statements being printed. So the control is reaching the desired UIViewController
but nothing is being displayed on the screen.
However, when changes are being made to the background view color from code (NOT the storyboard), only the background color covers the screen and shows up. None of the UI elements added from storyboard shows up. Please help me. Thank you.
Upvotes: 1
Views: 52
Reputation: 1712
It's because when you create it like this it's not created from the Storyboard. You need to reference it by ID in the Storyboard and load it that way.
UIStoryboard(name: "Main", bundle: nil).instantiateViewController("An Identifier You Set In The Storyboard")
https://developer.apple.com/documentation/uikit/uistoryboard
Upvotes: 1