用户界面-添加注销按钮在iPhone应用程序中随处可见



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

我已经使用UITabBarController来浏览我的视图,现在我需要添加一个注销按钮,使其始终可用/可见。

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

你能腾出一个选项卡项吗?这似乎是最干净的方式。然后你可以使用

  tabBarController:didSelectViewController: 

方法CCD_ 2。

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

-(void)tabBarController:(UITabBarController*)tabBarController didSelectViewController:{if([tabBarController selectedIndex]==4){//注销}}

最好的方法是使用右按钮位置。

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

只是猜测。您是否尝试将导航控制器用作根控制器?您可以使用右侧的BarButtonItem进行注销。

最新更新