On my storyboard I have 2 viewControllers, one with a background image and one with blur effect an a label
I would like to present the second view on top of the first one. I'm using the following code:
override func viewDidAppear(animated: Bool) {
var vc = self.storyboard?.instantiateViewControllerWithIdentifier("second") as secondViewController
self.view.addSubview(vc.view)
super.viewDidAppear(animated)
}
I'm using addSubView
and not presentViewController
, because the latest cause my first view to disappear after the transition completed, and all i got was a black screen.
as long as I don't add constraints to the second view, my code seems to be at the right direction (see below):
However, the moment I'm adding constraints to the second view, it will not show at all.
Q:What is the correct way of displaying a second view controller as an overlay and give it the right constraints
EDIT: I've tried to add vc.view.frame = self.view.frame
as suggested by @topher91. The view appears for an instants then disappears. Here is the debug view hierarchy: