Question

I am trying to add a subview to my iphone window and i have written the following code for that. Problem is that when the splash view or main menu view appears on the screen, it goes behind status bar. I mean the view starts from behind the status bar. Also both view overlap when the main menu view is show after the splash view. Can anyone please help? Thanks

- (void)applicationDidFinishLaunching:(UIApplication *)application {
       [window addSubView: [[Resources getResources] getSplashView]];
       [vindow makeKeyAndVisible];
       [self performSelector:@selector(displayMainMenuView) withObject:nil afterDelay:2.0];
  }


 -(void) displayMainMenuView {
       [window addSubView: [[Resources getResources] getMainMenuView]];`   
  }
Was it helpful?

Solution

You can also just adjust the frame of your main menu like:

mainMenuViewController.view.frame = CGRectMake(0.0f, 20.0f, 320.0f, 460.0f);

This will make your view just below the statusbar.

OTHER TIPS

Set the property statusBarHidden to YES when the splash view is displayed

- (void)applicationDidFinishLaunching:(UIApplication *)application {
       application.statusBarHidden = YES;
       [window addSubView: [[Resources getResources] getSplashView]];
       [vindow makeKeyAndVisible];
       [self performSelector:@selector(displayMainMenuView) withObject:nil afterDelay:2.0];
  }

This is what happens for the root view. Instead of using the addSubView method, try setting the window's rootViewController. Something like this:

  • (void)applicationDidFinishLaunching:(UIApplication *)application { window.rootViewController = [[Resources getResources] getSplashViewController]]; [vindow makeKeyAndVisible]; [self performSelector:@selector(displayMainMenuView) withObject:nil afterDelay:2.0]; }

    -(void) displayMainMenuView { window.rootViewController = [[Resources getResources] getMainMenuViewController]];
    }

Please note that you should set the controller object, not the view object. Thus you'd need getters like getMainMenuViewController in your case.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top