2

i am designing an iphone application which should be display login screen initially, after that it should display tab bar controller with 5 tabs. Am able to launch login screen initially, but after that am unble to show tab bar controller, kindly help me out with the source code guys. here is my code: this is a view based application

application.M

 -(void)applicationDidFinishLaunching:(UIApplication *)application {    

    // Override point for customization after app launch 
       [window addSubview:viewController.view]; 
    [window addSubview:tabBarController. view];   
    [window makeKeyAndVisible];
    LoginView *loginView=[[LoginView alloc]initWithNibName:@"LoginView" bundle:nil];
    [window addSubview:loginView.view];
}  

by doing this the tab bar controller is displaying at the bottom of the login screen initially.And also am unable to switch between the tab bar items.

Maulik
  • 19,348
  • 14
  • 82
  • 137
Karthik Varma
  • 59
  • 2
  • 11
  • you need to accept answers to your previous questions, it is discouraging for people to put effort into answering your questions if you can't be bothered to accept their answers. – Andrey Zverev Dec 15 '11 at 11:18

3 Answers3

3

What you can do is the following.

Launch the Tabbar as the main screen and then before the view is loaded or displayed show the logon screen and dismiss the logon screen after successful log on.

EDIT: For a code example look at code provided by Maulik

Armand
  • 9,847
  • 9
  • 42
  • 75
  • hi maulik can you help me out with the code for displaying logon screen initially and also how to dismiss the logon screen before tab bar controller is loaded?? and important note is am not using navigation controller – Karthik Varma Dec 14 '11 at 12:44
1

Try to do the following:

[window makeKeyAndVisible];
LoginView *loginView=[[LoginView alloc] initWithNibName:@"LoginView" bundle:nil];
[window addSubview:loginView.view];

You will want to show the loggin first. After the login done, you should send a message to your app delegate so he can switch between your login view and your tabBarController:

-(void)loginFinished{   
    window.rootViewController=tabBarController;
}

I advise you to:

1 - Have IBOutlets for your LoginViewController and UITabBarViewController, so you can easly use them.

2- Use a notifcation, so your app delegate knows when to switch the controllers.

Rui Peres
  • 25,741
  • 9
  • 87
  • 137
  • delegate.m[window makeKeyAndVisible]; LoginView *loginView=[[LoginView alloc] initWithNibName:@"LoginView" bundle:nil]; [window addSubview:loginView.view]; } -(void)loginFinished{ window.rootViewController=tabBarController; – Karthik Varma Dec 14 '11 at 12:26
0

Assuming you have TabBarController class by sub classing UITabBarController.

You can also push tab bar controller after the Login view complete its job.

In Login.m file

- (void) doLogin
{
  if(login)
  {
     TabBarController *aTabBarController = [[TabBarController alloc] initWithNibName:@"TabBarController" bundle:nil];
     [self.navigationController pushViewController:aTabBarController animated:YES];
     [aTabBarController release];    
  }
}
Maulik
  • 19,348
  • 14
  • 82
  • 137