• <tfoot id='Sxq5m'></tfoot>
      <bdo id='Sxq5m'></bdo><ul id='Sxq5m'></ul>
  • <small id='Sxq5m'></small><noframes id='Sxq5m'>

  • <legend id='Sxq5m'><style id='Sxq5m'><dir id='Sxq5m'><q id='Sxq5m'></q></dir></style></legend>

      1. <i id='Sxq5m'><tr id='Sxq5m'><dt id='Sxq5m'><q id='Sxq5m'><span id='Sxq5m'><b id='Sxq5m'><form id='Sxq5m'><ins id='Sxq5m'></ins><ul id='Sxq5m'></ul><sub id='Sxq5m'></sub></form><legend id='Sxq5m'></legend><bdo id='Sxq5m'><pre id='Sxq5m'><center id='Sxq5m'></center></pre></bdo></b><th id='Sxq5m'></th></span></q></dt></tr></i><div id='Sxq5m'><tfoot id='Sxq5m'></tfoot><dl id='Sxq5m'><fieldset id='Sxq5m'></fieldset></dl></div>

        为什么我的根视图的高度不考虑它的导航栏?

        Why doesn#39;t my root view#39;s height take account of its navigation bar?(为什么我的根视图的高度不考虑它的导航栏?)
      2. <small id='k88kL'></small><noframes id='k88kL'>

        <tfoot id='k88kL'></tfoot><legend id='k88kL'><style id='k88kL'><dir id='k88kL'><q id='k88kL'></q></dir></style></legend>
        <i id='k88kL'><tr id='k88kL'><dt id='k88kL'><q id='k88kL'><span id='k88kL'><b id='k88kL'><form id='k88kL'><ins id='k88kL'></ins><ul id='k88kL'></ul><sub id='k88kL'></sub></form><legend id='k88kL'></legend><bdo id='k88kL'><pre id='k88kL'><center id='k88kL'></center></pre></bdo></b><th id='k88kL'></th></span></q></dt></tr></i><div id='k88kL'><tfoot id='k88kL'></tfoot><dl id='k88kL'><fieldset id='k88kL'></fieldset></dl></div>
          <bdo id='k88kL'></bdo><ul id='k88kL'></ul>
            <tbody id='k88kL'></tbody>

                  本文介绍了为什么我的根视图的高度不考虑它的导航栏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我的印象是 UINavigationController 的导航栏总是会向下推子视图的高度,这样子视图的原点就在标题栏的底部.

                  I was under the impression that a UINavigationController's navigation bar would always push down the child view's height, such that the child view's origin was at the bottom of the title bar.

                  但是当我呈现这样的视图控制器时......

                  But when I present a view controller like this ...

                  MyViewController *viewController = [[MyViewController alloc] init];
                  UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
                  viewController.title = @"My View Controller";
                  viewController.navigationItem.prompt = @"My Prompt";
                  viewController.delegate = self;
                  
                  [self presentModalViewController:navigationController animated:YES];
                  [navigationController release]; [viewController release];
                  

                  ... 然后用 viewDidLoad 中的 NSLog 检查 self.view.frame.size.height,它报告我的视图是 460px 高.它不应该减去我标题的高度吗?迅速的?

                  ... and then check self.view.frame.size.height with an NSLog in viewDidLoad, it reports that my view is 460px high. Shouldn't it subtracting the height of my title & prompt?

                  推荐答案

                  所以,按照要求:

                  当您调用 viewDidLoad 时,视图控制器还没有被推送到屏幕上.因此,当您从该方法中获取帧大小时,它将报告其默认值(对于 iPhone 应用,通常为 320x480).

                  When you call viewDidLoad the view controller hasn't been pushed onto the screen yet. So when you get the frame size from within that method it will report its' default (typically, 320x480 for an iPhone app).

                  然后视图会自动调整大小以考虑导航栏.因此,当您在 viewWillAppear 中检查帧大小时,它现在是正确的.通常这对 iPhone 应用程序来说不是问题.对于 iPad 应用程序,您有多个方向,这可能会有点痛苦!

                  The view then autoresizes to take into account the navigation bar. So when you check the frame size in viewWillAppear it will now be correct. Typically this isn't a problem for iPhone apps. For iPad apps, where you have multiple orientations, it can be a bit of a pain!

                  这有一些例外 - 例如,使用 NIB 时.

                  There are a few exceptions to this - for example, when using NIBs.

                  这篇关于为什么我的根视图的高度不考虑它的导航栏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  UINavigationController inside a UITabBarController inside a UISplitViewController presented modally on iPhone(UISplitViewController 内的 UITabBarController 内的 UINavigationController 以模态方式呈现在 iPhone 上) - IT屋-程序员软件开发技术分
                  ViewController in UINavigationController orientation change(UINavigationController 中的 ViewController 方向更改)
                  Custom back button in UINavigationController(UINavigationController 中的自定义后退按钮)
                  How to add a navigation controller programmatically in code but not as initial view controller(如何在代码中以编程方式添加导航控制器,但不作为初始视图控制器)
                  How to get the previous viewcontroller that pushed my current view(如何获取推送我当前视图的上一个视图控制器)
                  The correct way to set a light status bar text color in iOS 7 based on different ViewControllers(iOS 7中基于不同ViewControllers设置灯光状态栏文字颜色的正确方法)
                    <bdo id='2oTno'></bdo><ul id='2oTno'></ul>
                      <tbody id='2oTno'></tbody>

                      <i id='2oTno'><tr id='2oTno'><dt id='2oTno'><q id='2oTno'><span id='2oTno'><b id='2oTno'><form id='2oTno'><ins id='2oTno'></ins><ul id='2oTno'></ul><sub id='2oTno'></sub></form><legend id='2oTno'></legend><bdo id='2oTno'><pre id='2oTno'><center id='2oTno'></center></pre></bdo></b><th id='2oTno'></th></span></q></dt></tr></i><div id='2oTno'><tfoot id='2oTno'></tfoot><dl id='2oTno'><fieldset id='2oTno'></fieldset></dl></div>

                      <small id='2oTno'></small><noframes id='2oTno'>

                        <tfoot id='2oTno'></tfoot>
                        <legend id='2oTno'><style id='2oTno'><dir id='2oTno'><q id='2oTno'></q></dir></style></legend>