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子類來處理模式視圖的顯示/解除... –