ios - Warning: Attempt to present UINavigationController whose view is not in the window hierarchy? -
i doing appdelegate. have 2 storyboards, main storyboard , secondstoryboard. when set main interface secondstoryboard deployment info of app target, , run project following code works charm.
but when set main interface main story board deployment info of app target, , run project throwing warning , presentviewcontroller method not working.
:( pls ! in advance.
var storyboard: uistoryboard = uistoryboard(name: "secondstoryboard", bundle: nil) var congratulationscreen = storyboard.instantiateviewcontrollerwithidentifier("s_id_secondvc") as! secondvc var navcontroller = uinavigationcontroller(rootviewcontroller: congratulationscreen) self.window?.makekeyandvisible() self.window?.rootviewcontroller?.presentviewcontroller(navcontroller, animated: true, completion: nil)
check call after delay dispatch queue
let delaytime = dispatch_time(dispatch_time_now, int64(0.1*double(nsec_per_sec))) dispatch_after(delaytime, dispatch_get_main_queue()) { var storyboard: uistoryboard = uistoryboard(name: "secondstoryboard", bundle: nil) var congratulationscreen = storyboard.instantiateviewcontrollerwithidentifier("s_id_secondvc") as! secondvc var navcontroller = uinavigationcontroller(rootviewcontroller: congratulationscreen) self.window?.makekeyandvisible() self.window?.rootviewcontroller?.presentviewcontroller(navcontroller, animated: true, completion: nil) }
Comments
Post a Comment