导航控制器的差距

0 iphone uinavigationbar uinavigationcontroller

我在视图上有一个按钮.当我点击它时,它应该加载另一个视图,一个带有novigation控制器.到目前为止,我已经有了这个,按钮调用这个方法:

-(IBAction)loadOptionsView:(id)sender {

     if (self.optionsRootController == nil) {

          //optionsRootController is declared as: UINavigationController *optionsRootController;
          optionsRootController = [[UINavigationController alloc] init];

          //Options is a UIViewController
          Options *myOptions = [[Options alloc] initWithNibName:@"OptionsMenu" bundle:nil];
          [optionsRootController pushViewController:myOptions animated:NO];
          [myOptions release];
     }

     [self.view addSubview:optionsRootController.view];

}
Run Code Online (Sandbox Code Playgroud)

单击按钮时会发生什么,它会在当前屏幕顶部加载xib文件OptionsMenu,但状态栏大小顶部有一个间隙,所以我可以看到下面的视图.有帮助吗?加载包含导航控制器的新视图的正确方法是什么?

谢谢你们!

小智 5

我通过以下方式解决了这个问题:

[optionsRootController pushViewController:myOptions animated:NO];
Run Code Online (Sandbox Code Playgroud)

这一行:

[optionsRootController.view setFrame: [self.view bounds]];
Run Code Online (Sandbox Code Playgroud)

好,易于!