【问题标题】:Loging out issue in iphone sdkiphone sdk中的注销问题
【发布时间】:2011-09-26 05:12:54
【问题描述】:

我已经创建了一个基于标签栏的 iphone 应用程序,对于登录页面我使用了以下方法:

@protocol LoginViewControllerDelegate;
@interface TradeBarcodeViewController: UIViewController{
id<LoginViewControllerDelegate> delegate;
}
@protocol LoginViewControllerDelegate
-(void)loginViewControllerDidFinish:(TradeBarcodeViewController *)loginViewController;
@end

@implementation TradeBarcodeViewController

[self.delegate loginViewControllerDidFinish:self];
@end

它工作正常,我可以登录到标签栏控制的应用程序。在其中一个标签栏 viewconroller 中有一个用于注销的按钮。我为此使用了以下内容:

TradeBarcodeViewController *vc = [[TradeBarcodeViewController alloc]init];
    [self presentModalViewController:vc
                            animated:NO];
    [vc release];

然后它会再次导航到登录页面,但如果我再次尝试登录它就无法正常工作。这里出了什么问题?或者我应该使用哪种方法从我的应用程序中注销? 谢谢。

【问题讨论】:

  • 在注销操作中使用 [self popToRootViewControllerAnimated:YES];
  • 我试过了,但是应用程序崩溃了,并且登录窗口不是tabbar控制器的viewcontrollers之一。
  • 因为注销按钮位于 Tabbar 控件之一中,所以我使用了 [self.navigationController popToRootViewControllerAnimated:YES];现在应用程序没有崩溃,也没有警告。但什么都没有发生。
  • 我调用了一个网络服务,并根据我登录的结果。我使用我帖子中的代码进行日志记录。
  • 你推送你的登录页面吗..like [self.navigationController pushViewController:abc animated:YES];

标签: iphone logout tabbarcontroller


【解决方案1】:

如果您的登录页面不在标签栏中,那么当您单击注销时使用此代码

//这里你需要清除数据库中检查用户名和密码的字段 [tabBar.view removeFromSuperview];

[tabBar 释放];

tabBar = nil;

[自我添加登录页面];

然后在 addLoginPage 函数中添加这个

LoginPageViewController *loginView = [[LoginPageViewController alloc] init];

navigation=[[UINavigationController alloc]initWithRootViewController:loginView];


[window addSubview:navigation.view];

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-08-24
    • 1970-01-01
    • 2011-09-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-25
    相关资源
    最近更新 更多