'how can I show or present a ViewController correctly?
Whenever I show my ViewController, I get the error:
Meusic[53572:4085718] <UIView: 0x129e0bc60; frame = (0 0; 375 729); autoresize = W+H; layer = <CALayer: 0x6000005ba1c0>>'s window is not equal to <UINavigationController: 0x127011400>'s view's window!
Currently the preferencesViewcontroller doesnt have any anything. In there a reason on why this happens? I
func preferencesButtonWasPressed() {
print("preferencesButtonWasPressed - view didload")
let root = PreferencesViewController()
let navController = UINavigationController(rootViewController: root)
navController.modalPresentationStyle = .fullScreen
self.show(navController, sender: self)
}
I was expected for it to show the ViewController without any error since it has worked before.
Solution 1:[1]
Initialise your ViewController through Storyboard initialisation first.
guard let vc = UIStoryboard(name: "PreferencesViewController", bundle: nil).instantiateViewController(withIdentifier: "PreferencesViewControllerIdentifier") as? PreferencesViewController else {
return
}
self.present(vc, animated: true, completion: nil)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Peter Papajohn |
