2011-07-13 7 views
3

おはよう、CustomViewController内から(AppDelegateの)RootViewControllerを変更するにはどうすればいいですか?

私のアプリは、AppDelegateで読み込まれたサインインした後(SigninController.mにチェックが入っています)、TabBarControllerが(アプリケーションのメインビューとして)表示されます。

コントローラをSigninからTabBarに変更するにはどうすればよいですか?

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
    { 
SigninController *aSigninController = [[SigninController alloc] initWithNibName:@"SigninView" bundle:nil]; 
self.currentController = aSigninController; 
[aSigninController release]; 

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

SigninController.m

- (IBAction)signinClick 
{ 
........ 
if (loginOK == YES) 
{   
     //This place is ready to send messages to show TabBar 
} else { 
    UIAlertView *alert = ...... 
    [alert show]; 
    [alert release]; 
}  
} 
+0

使用しているプログラミング言語にタグを付けてください。 –

答えて

8
[appDelegate.window addSubview:appDelegate.tabbarController.view]; 

[self.view removeFromSuperview]; 

appDelegateは、アプリケーション共有デリゲートです。

MyAppDelegate *delegate = (MyAppDelegate *)[[UIApplication sharedApplication] delegate]; 
+0

SigninControllerのヘッダファイルに#import "MyAppDelegate.h"を追加しましたか? – LIAL

+0

はい、それを追加する必要があります... – makboney

+0

私は 'self.view.window.rootViewController = self.loadThisViewWhenDone'を使用して私のタブバーコントローラをロードしていましたが、これはナビゲーションバーコントローラを設定しようとすると動作を停止しました!私はなぜあなたのコードを使用して助けたのか分かりません:) – pulkitsinghal

関連する問題