IPhone - View隐藏在状态栏后面

时间:2010-07-21 07:39:50

标签: iphone view statusbar behind

我正在尝试将子视图添加到我的iphone窗口,并为此编写了以下代码。问题是当飞溅视图或主菜单视图出现在屏幕上时,它会在状态栏后面。我的意思是视图从状态栏后面开始。当在飞溅视图之后显示主菜单视图时,两个视图都重叠。有人可以帮忙吗? 感谢

- (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]];`   
  }

3 个答案:

答案 0 :(得分:2)

您也可以调整主菜单的框架,如:

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

这会使您的视图位于状态栏下方。

答案 1 :(得分:0)

显示初始视图时,将属性statusBarHidden设置为YES

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

答案 2 :(得分:0)

根视图会发生这种情况。而不是使用addSubView方法,尝试设置窗口的rootViewController。像这样:

  • (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 ]];
    }

请注意,您应该设置控制器对象,而不是视图对象。因此,你需要像getMainMenuViewController这样的getter。