我正在构建一个iPhone应用程序,要求用户输入他的凭据才能使用该应用程序,并且可以随时注销。
我使用UITabBarController
浏览我的观看次数,现在我需要以一直可用/可见的方式添加Logout按钮。
有人可以为此案例提出解决方案或最佳做法吗?
答案 0 :(得分:1)
最好的方法是使用右按钮位置。
UIBarButtonItem *saveButton = [[UIBarButtonItem alloc]
initWithTitle:@"Logout"
style:UIBarButtonItemStylePlain
target:self
action:@selector(yourLogoutSelector)];
self.navigationItem.rightBarButtonItem = saveButton;
[saveButton release];
答案 1 :(得分:1)
你能为那个备用标签栏项目吗?这似乎是最干净的方式。然后你可以使用
tabBarController:didSelectViewController:
UITabBarControllerDelegate
。
类似的东西(假设退出标签是第5个标签)
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController { if ([tabBarController selectedIndex] == 4) { //LOGOUT } }
答案 2 :(得分:0)
只是一个猜测。您是否尝试将导航控制器用作根控制器?您可以使用rightBarButtonItem进行注销。