I have created an tabbar based iphone app, for the login page i used the following method:
@protocol LoginViewControllerDelegate;
@interface TradeBarcodeViewController: UIViewController{
id<LoginViewControllerDelegate> delegate;
}
@protocol LoginViewControllerDelegate
-(void)loginViewControllerDidFinish:(TradeBarcodeViewController *)loginViewController;
@end
@implementation TradeBarcodeViewController
[self.delegate loginViewControllerDidFinish:self];
@end
It is working fine and I can loggin to the tabbar controled app. In one of the tabbar viewconroller there is a button for Logout. I used the following for that:
TradeBarcodeViewController *vc = [[TradeBarcodeViewController alloc]init];
[self presentModalViewController:vc
animated:NO];
[vc release];
Then 开发者_如何学Cit will again navigate to the login page, but if I try to login again it is not working. What went wrong here? Or which method should I use to logout from my app? Thanks.
if your login page is not in tabbar then when u click logout use this code
//here u need to clear the field from database which checks for username and password [tabBar.view removeFromSuperview];
[tabBar release];
tabBar = nil;
[self addLoginPage];
Then in addLoginPage function add this
LoginPageViewController *loginView = [[LoginPageViewController alloc] init];
navigation=[[UINavigationController alloc]initWithRootViewController:loginView];
[window addSubview:navigation.view];
精彩评论