I would like to simply show a second ViewController from a already active ViewController by code. I would like to do this as much as possible with only coding (instead of drag and drop thing in the storyboard)
I tried to do as follow, but the second view doesn't popup.
My Storyboard. Left is the initial view, right is the view I like to open from the initial view. In the screen is the right view clicked, so you can see the properties on the right:
My initial UIViewcontroller class:
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad();
dosomestuff();
showTimeline(); // << --------------------
}
func showTimeline() {
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewControllerWithIdentifier("Timeline") as! UIViewController
self.presentViewController(vc, animated: true, completion: nil)
//self.showViewController(vc, sender: self);
}
Question Update, because it is unclear what I am asking : When I start the App only the first screen is present. No crash just a Warning in the Log "Warning: Attempt to present on whose view is not in the window hierarchy!"
any help how to do this ?