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

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -