我遇到以下问题。使用UITabBarController登录/注销?
大气压我有向用户发送到tabbarcontroller.After验证用户被发送到tabbarcontroller用下面的代码一个LoginView:
-(void)userSuccessfullyLoggedIn{
[self.window setRootViewController:myTabBarController];
[myTabBarController setSelectedIndex:0];
[self.window makeKeyAndVisible];
}
在此之后,用户被成功地发送到所述第一视图在标签栏中。
标签栏上的第五项保留一个空视图,用于将用户从tabbarcontroller“注销”回到LoginView。
// The following code intercepts the popup that confirms the "log out" dialog.
-(void)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
// index 0 is the YesButton that is supposed to "log out" the user.
if (buttonIndex == 0)
{
myAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
[appDelegate userLogsOut];
}
else{
NSLog(@"The user chose not to logout. Passing the user to the first tab");
[[self myTabBarController] setSelectedIndex:0];
}
}
的〔委托userLogsOut]代码如下:
-(void)userLogsOut{
[self.window setRootViewController:myLoginViewController]
[self.window makeKeyAndVisible];
}
现在来描述该问题。
它的工作原理与我想要的一样,除了当用户再次登录并且应该在保存第一个视图的第一个标签上时,来自空白logoutView的弹出对话框才会出现。
第一个视图在后台可见,如果选择不注销,对话框消失,如果用户此时选择YES,则用户会再次注销。
感谢您的阅读,任何提示和/或指针将高度赞赏。提前致谢。
我想实现一个类似的问题 - 从它的登录名和标签栏控制器。你在登录中定义了myTabBarController?我正在使用故事板。谢谢! – Dejell 2013-02-20 14:04:22
'UITabBarController'在'UIApplicationDelegate'中定义。这是没有故事板。 – doge 2013-02-21 09:48:01