0

I have an app that has a login screen and splash screen. I want these screens to show up one after the other, and as such I have resulted to adding them as subviews to the app delegate's window property.

[window addSubview:mainViewController.view];
[window addSubview:loginViewController.view];
[window addSubview:splashScreenViewController.view];

The problem is that each subsequent subview that is added seems to appear in a weird manner(the orientation of the nib file is not obeyed). I know my nib files are not at fault, because if I only include one view, no matter which view it is, it shows up right. Furthermore, if I add the views as subviews to the main view controller's view(as opposed to app delegates) view, i dont get this issue. However, there is a 20px gap at the bottom of the screen because I guess UIWindow accounts for the status bar, and normal UIView's do not.

Does anyone have any idea what the problem might be? Is UIWindow doing something special? Am I not supposed to add several subviews to UIWindow? If anyone has tips regarding how to do splash screens, that would be much appreciated.

Ying
  • 1,944
  • 5
  • 24
  • 38

3 Answers3

1

I suggest you use a UIView in the middle...

UIView view = [[UIView alloc] init];
[view addSubview:mainViewController.view];
[view addSubview:loginViewController.view];
[view addSubview:splashScreenViewController.view];
[window addSubview:view];
[view release];

After what if you what to animate as a splash screen, take a look at one of my post : how to open a new uiview like a popup?

Community
  • 1
  • 1
TheSquad
  • 7,385
  • 8
  • 40
  • 79
  • I guess this is the closest to what I am looking for, but this still means that I have to add it to a subview of window, and not have the view be a subview of window itself. I am still confused as to why UIWindow is behaving in a strange way when I try to attach a subview to it. Thanks for all the help though. – Ying Sep 05 '10 at 15:14
  • UiWindow is not meant to handle more than one subview... I have tried it when I started coding for iPhone, it never gave me the appropriate result. – TheSquad Sep 09 '10 at 16:11
0

You should only have 1 view controller at a time.

progrmr
  • 75,956
  • 16
  • 112
  • 147
0

You should use the -(void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController delegate function to check which tab was clicked. If it's your second view (which it should be if there are only 2 tabs) then call a custom method in your splashscreencontroller that pops up the modal. If that splash screen is only supposed to show once, make sure to set a flag afterwards to make sure it doesn't pop up again.

A TabBarController loads all the views before displaying them, so there's no lag when a user switches between tags.

MishieMoo
  • 6,620
  • 2
  • 25
  • 35