Reputation: 289
My app has a logout button and when the user hits that button, I need to kill all the existing views and background tasks (though I don't want to see the launch image again).
How can I accomplish this?
Upvotes: 2
Views: 622
Reputation: 379
The way I usually handle this is to have the LoginViewController be the RootViewController of the app with a NavigationController. On the LoginController I set the NavigationBar to be hidden.
Then it's just a simple.
[self.navigationController popToRootViewControllerAnimated:NO];
And all of your views are gone/killed (if you built them properly) so you'll only have to handle killing off any background processes that are not managed by the views.
Upvotes: 1
Reputation: 108091
In order to kill the views, just change the rootViewController
property of the window
.
Something like
self.window.rootViewController = //The new view controller to be presented here
In order to kill the background tasks it depends on the nature of the tasks. If you have a reference to them, you can kill them manually when logging out.
Upvotes: 0