iphone sdk 中的注销问题
我创建了一个基于标签栏的 iPhone 应用程序,对于登录页面,我使用了以下方法:
@protocol LoginViewControllerDelegate;
@interface TradeBarcodeViewController: UIViewController{
id<LoginViewControllerDelegate> delegate;
}
@protocol LoginViewControllerDelegate
-(void)loginViewControllerDidFinish:(TradeBarcodeViewController *)loginViewController;
@end
@implementation TradeBarcodeViewController
[self.delegate loginViewControllerDidFinish:self];
@end
它工作正常,我可以登录到标签栏控制的应用程序。在选项卡栏视图控制器之一中有一个用于注销的按钮。我为此使用了以下内容:
TradeBarcodeViewController *vc = [[TradeBarcodeViewController alloc]init];
[self presentModalViewController:vc
animated:NO];
[vc release];
然后它将再次导航到登录页面,但如果我尝试再次登录,它将无法正常工作。这里出了什么问题?或者我应该使用哪种方法从我的应用程序注销? 谢谢。
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 it 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您的登录页面不在选项卡栏中,那么当您单击注销时,请使用此代码
//这里您需要清除数据库中检查用户名和密码的字段
[tabBar.viewremoveFromSuperview];
[tabBar释放];
选项卡栏 = nil;
[自行添加登录页面];
然后在 addLoginPage 函数中添加这个
LoginPageViewController *loginView = [[LoginPageViewController alloc] init];
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];