3

Good day,

My app has authorization form (SigninController) which is loaded in AppDelegate, and after signing in (checking is in SigninController.m) TabBarController should appear (as main view of application).

How can I change controller from Signin to TabBar and where ??

- (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];
}    
}
LIAL
  • 1,624
  • 4
  • 24
  • 30

1 Answers1

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

[self.view removeFromSuperview];

appDelegate is the application shared delegate.

MyAppDelegate *delegate = (MyAppDelegate *)[[UIApplication sharedApplication] delegate];
makboney
  • 1,808
  • 1
  • 17
  • 34
  • Have I to add #import "MyAppDelegate.h" in header file of SigninController ? – LIAL Jul 13 '11 at 08:55
  • I was using `self.view.window.rootViewController = self.loadThisViewWhenDone`for loading my tab bar controller but that stopped working when I tried to set a nav bar controller! I'm not sure why but using your code helped :) – pulkitsinghal Jan 31 '13 at 22:18
  • It's a great answer. I think it would be nicer to reorder the code lines, so they are in the correct order and rename delegate to appDelegate. – eladleb Jun 28 '13 at 10:01