Reputation: 165
I am trying to implement a way for a user to logout of my app through a custom tabBarController. I have 5 tabBarItems, and I want the first one to be a logout tabBarItem - so when a user taps on it, an alertview pops up asking "are you sure you want to logout?". Is this possible - and if so what would be the best way about implementing this feature?
thanks!
-Matt
Upvotes: 0
Views: 47
Reputation: 3271
That seems like an unintuitive UI. I would consider redesigning so that there is a logout button somewhere within a view controller, toolbar or navigation bar.
With that said, if you really, really insist on making a "logout" tab bar item, you can create a UIViewController
that presents a UIAlertView
in viewDidAppear:
and implements the UIAlertViewDelegate
protocol. Then in alertView:clickedButtonAtIndex:
you can update your global state to handle a logout (i.e. broadcast a notification through NSNotificationCenter
, make a custom AppDelegate call, etc.).
Upvotes: 1