UINavigationController within ViewController, gap at top of view

后端 未结 11 1000
不知归路
不知归路 2021-02-04 03:24

I\'m working on a universal app, and I\'m trying to share as much code as possible between the iPhone and iPad versions. I need to use a TabBarController as my root view contro

11条回答
  •  别那么骄傲
    2021-02-04 03:33

    UINavigationController is normally displayed as a full-screen controller, which means that (when displayed as the root view controller of the window) the top part of its view is placed under the status bar. It then manually positions its navigation bar and content view to not underlap the status bar when the status bar is visible. Unfortunately, it doesn't really handle things correctly when it is being positioned by some other view controller, it (sometimes) assumes it needs to leave that 20px gap without checking whether its view actually is under the status bar.

    The solution is to set wantsFullScreenLayout on the UINavigationController to NO, so it won't even attempt to leave that gap for the status bar.

提交回复
热议问题