添加注销按钮,使其在iPhone应用程序中随处可见

添加注销按钮,使其在iPhone应用程序中随处可见,iphone,user-interface,user-experience,Iphone,User Interface,User Experience,我正在构建一个iPhone应用程序,该应用程序要求用户输入其凭据才能使用该应用程序,并且可以随时注销 我使用了UITabBarController在视图中导航,现在我需要添加一个随时可用/可见的注销按钮 有人能为这种情况提出解决方案或最佳做法吗?只是一个猜测。您是否尝试将导航控制器用作根控制器?您可以使用RightBarButtonim注销 最好的方法是使用右键位置 UIBarButtonItem *saveButton = [[UIBarButtonItem alloc]

我正在构建一个iPhone应用程序,该应用程序要求用户输入其凭据才能使用该应用程序,并且可以随时注销

我使用了
UITabBarController
在视图中导航,现在我需要添加一个随时可用/可见的注销按钮


有人能为这种情况提出解决方案或最佳做法吗?

只是一个猜测。您是否尝试将导航控制器用作根控制器?您可以使用RightBarButtonim注销

最好的方法是使用右键位置

UIBarButtonItem *saveButton = [[UIBarButtonItem alloc]
                               initWithTitle:@"Logout"
                               style:UIBarButtonItemStylePlain
                               target:self
                               action:@selector(yourLogoutSelector)];
self.navigationItem.rightBarButtonItem = saveButton;
[saveButton release];

你能为它预留一个选项卡栏项目吗?这似乎是最干净的方式。然后你可以用

  tabBarController:didSelectViewController: 
UITabBarControllerDelegate的方法

类似的东西(假设注销选项卡是第5个选项卡)

-(void)tabBarController:(UITabBarController*)tabBarController didSelectViewController:(UIViewController*)viewController{ 如果([tabBarController selectedIndex]==4){ //注销 } }
您想让它显示一个视图,还是像一个按钮那样让用户在没有视图的情况下注销?它将引导用户返回登录视图这需要与标准UITabBarController设置不同吗?为什么你不能在标签栏上添加一个注销按钮呢?我已经考虑过了。你认为这是这里最好的用户体验吗?如果不更好地了解你在做什么,看看你的UI布局,很难说。我喜欢这个想法,接近
j0k
所说的。 - (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController { if ([tabBarController selectedIndex] == 4) { //LOGOUT } }