I’m having issues with the following.
Atm i have a LoginView that sends the user to a tabbarcontroller.After verification the user is sent to the tabbarcontroller with the following code:
-(void)userSuccessfullyLoggedIn{
[self.window setRootViewController:myTabBarController];
[myTabBarController setSelectedIndex:0];
[self.window makeKeyAndVisible];
}
After this, the user is successfully sent to the first view in the tabbar.
The 5th item on the tab-bar holds an empty view to “log out” the user from the tabbarcontroller back to the 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];
}
}
The [delegate userLogsOut] code is as follows:
-(void)userLogsOut{
[self.window setRootViewController:myLoginViewController]
[self.window makeKeyAndVisible];
}
And now to describe the problem.
It works just as i want it, except for when the user logs back in again and is supposed to land on the first tab holding the first view, the popup dialog from the empty logoutView just appears out of nowhere.
The first view is visible in the background, and if selected NOT to log out, the dialog disappears, if the user is selecting YES at this point, the user gets logged out again.
Thanks for reading, and any tips and/or pointers will be highly appreciated. Thanks in advance.
Sorry I cannot test it now, but I think when you log in for the second time, the Logout tab (fifth tab) is still active when
[self.window setRootViewController:myTabBarController];was called, before you selected the first tab with[myTabBarController setSelectedIndex:0];. You could try switching the first and second lines in- (void)userSuccessfullyLoggedInlike: