我遇到以下問題。使用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