Last active
September 5, 2022 07:27
-
-
Save michaelevensen/3bbd36e417e463c01368ff5669a428c0 to your computer and use it in GitHub Desktop.
Embed a UIViewController in Container View programatically
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Instantiate | |
self.mapViewController = self.storyboard?.instantiateViewController(withIdentifier: "MapViewController") as? MapViewController | |
if let mapViewController = self.mapViewController { | |
// Add to Container View | |
self.mapViewContainerView.addSubview(mapViewController.view) | |
self.addChildViewController(mapViewController) | |
mapViewController.didMove(toParentViewController: self) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
willMove
documentation:Looks like there is no need to call the
willMove
method since just after that you call theaddChildViewController