ios - View hierarchy error while presenting a viewcontroller -
i have following class:
class homeviewcontroller: uiviewcontroller { override func viewdidload() { super.viewdidload() callothervc() } func callothervc() { let viewcontroller = stepsviewcontroller() let rootviewcontroller = uinavigationcontroller(rootviewcontroller: viewcontroller) self.presentviewcontroller(rootviewcontroller, animated: true, completion: nil) } } stepsviewcontroller viewcontroller. in stepsviewcontroller, try dismiss current stepsviewcontroller , present other viewcontroller. following code.
class stepsviewcontroller: uiviewcontroller { override func viewdidload() { super.viewdidload() callsecondothervc() } func callsecondothervc() { let vc = viewcontroller() self.addchildviewcontroller(vc) self.parentviewcontroller!.dismissviewcontrolleranimated(true, completion: nil) vc.callothervc() } } i initialize viewcontroller() because need call same function callothervc viewcontroller. model in viewcontroller changes i'm calling same uinavigationcontroller callothervc function.
whenever this, error below:\
warning: attempt present (uinavigationcontroller: 0x7d991600) on (homeviewcontroller: 0x7a6e00a0) view not in window hierarchy!
uinavigationcontroller callsecondothervc , homeviewcontroller is.
how should order vcs? , if can more explain view hierarchy, appreciate.
i think need here, call method viewdidappear, rather viewdidload. reason view not in view hierarchy @ time of viewdidload.
Comments
Post a Comment