0

我正在实施一个应用程序,在该应用程序中显示带有显示模式视图的导航项按钮的视图。此模式视图显示登录表单。如果登录是正确的,我想去另一个视图显示一个标签栏2或3控制器。 到目前为止,在我的AppDelegate我有:登录后显示标签栏iPhone应用程序

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 

self.window.rootViewController = self.navigationController; 
[self.window makeKeyAndVisible]; 
return YES; } 

,然后在我的RooViewController我有:

- (void)viewDidLoad { 
HomeViewController *homeController = [[HomeViewController alloc] initWithNibName:@"HomeViewController" bundle:nil]; 
self.controladorVistaHome = homeController; 
[self.view addSubview:homeController.view]; 
[homeController release]; 

self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Login" style: UIBarButtonItemStyleBordered target:self action:@selector(showModalLoginForm)]; 
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Register" style: UIBarButtonItemStyleBordered target:self action:@selector(showModalRegisterForm)]; 
[super viewDidLoad]; } 

当我点击登录按钮,它让我看到一个模式与形式查看。一旦用户登录,我想用一些控制器显示一个NAB栏视图。 如果我修改我的AppDelegate,那么我到目前为止不会工作。有没有办法做到这一点? 在此先感谢!

回答

0

通常,UITabBarController是您的应用程序的绝对根目录,然后根据需要将UINavigationControllers添加到每个选项卡视图。

我建议将self.window.rootViewController更改为UITabBarController(这将成为用户登录后应用程序的主要中心)。 然后在第一次启动时,如果用户没有登录,则抛出一个模式View,以便他们登录或注册。

如果登录成功,请关闭模态视图。然后你会回到你的标签栏准备好应用程序的主要用途。

如果用户没有登录,则显示另一个模式视图进行注册,一旦完成(或者甚至可以自动将用户注册为&,因此被解散),该视图将退回到原始日志模式视图。

+0

在第一次启动时应该抛弃哪种模式视图?在我的AppDelegate?通过修改AppDelegate,我感到困惑... – Ruben

+0

所有这些验证(用户登录,用户注销...),我应该让他们在AppDelegate上? – Ruben

+0

不要害怕修改AppDelegate,但我会考虑创建一个UITabBarController子类来处理模式视图的显示/解除... –