2011-07-13 2 views
3

Bonjour,Comment modifier RootViewController (dans AppDelegate) à partir de CustomViewController?

Mon application a une forme d'autorisation (SigninController) qui est chargé dans AppDelegate, et après la signature de (vérification est en SigninController.m) TabBarController doit apparaître (comme vue principale de l'application).

Comment changer le contrôleur de Signin à TabBar et où ??

- (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

Veuillez marquer le langage de programmation que vous utilisez. –

Répondre

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

[self.view removeFromSuperview]; 

appDelegate est l'application délégué partagé.

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

Ai-je besoin d'ajouter #import "MyAppDelegate.h" dans le fichier d'en-tête de SigninController? – LIAL

+0

oui vous devez l'ajouter ... – makboney

+0

J'utilisais 'self.view.window.rootViewController = self.loadThisViewWhenDone'pour charger mon contrôleur de barre d'onglets mais cela a cessé de fonctionner quand j'ai essayé de configurer un contrôleur de barre de navigation! Je ne sais pas pourquoi mais en utilisant votre code aidé :) – pulkitsinghal

Questions connexes