I am building an app to present UIViewController
and dismiss the current UIViewController
at the same time.
Currently I'm in viewcontroller1
and i want to present viewcontroller2
as main controller and dismiss viewcontroller1
to remove it from memory, so viewcontroller2
will be the main controller after presenting and there is no viewcontroller1
in stack.
I've tried :
let controller = storyboard?.instantiateViewControllerWithIdentifier("controller2") as! viewcontroller2
controller.modalTransitionStyle = UIModalTransitionStyle.CrossDissolve
self.dismissViewControllerAnimated(false) { () -> Void in
self.presentViewController(controller, animated: false, completion: nil)
}
But it gave me : 0x7fee28711900> whose view is not in the window hierarchy!
Is there is a way to do that ?