ios - How to reset root view controller -
is possible reset root view controller? reset mean resetting initial state viewdidload
called again. i'm using uitabbarcontroller
, when logout want tabs loaded unloaded.
you can setting instance of tabbarcontroller rootviewcontroller on logout action.
swift 3:
let storyboard = uistoryboard(name: "main", bundle: nil) let tabbarcontroller = storyboard.instantiateviewcontroller(withidentifier: "tabbarcontroller") as! uitabbarcontroller uiapplication.shared.keywindow?.rootviewcontroller = tabbarcontroller uiapplication.shared.keywindow?.makekeyandvisible()
objective c:
uistoryboard *storyboard = [uistoryboard storyboardwithname:@"main" bundle:nil]; uitabbarcontroller *tabbarcontroller = [storyboard instantiateviewcontrollerwithidentifier:@"tabbarcontroller"]; [[[uiapplication sharedapplication] keywindow] setrootviewcontroller:tabbarcontroller]; [[[uiapplication sharedapplication] keywindow] makekeyandvisible];
Comments
Post a Comment