我有一个仅支持 ios7+ 的应用程序 导航栏设置使用状态栏下方显示的新 64 像素高栏。应用程序启动时如下所示:
如果我执行任何类型的“presentViewController”,当我关闭 View 时,导航栏会移回到 44px 高度,并且仍然出现在状态栏下方,这反过来又会使 View 的所有内容也向上移动。看起来像这样:
无论我是呈现我自己的 View 之一还是只是呈现 UIImagePickerView,任何类型的通过导航 Controller 向上滑动的模式都会破坏导航栏设置。关于如何解决这个问题有什么想法吗?
一些注意事项:
- 在 plist 中:“查看基于 Controller 的状态栏外观”设置为“NO”
- 导航栏配置为 self.navController.navigationBar.translucent = NO;
- 我使用的是 .xib 而不是 Storyboard
更新:
我的导航 Controller 位于 PKRevealController ( https://github.com/pkluz/PKRevealController ) 内。取出显示 Controller 并将导航 Controller 添加到窗口本身就可以解决问题...为什么显示 Controller 会导致其行为不同?
解决方案:
事实证明 PKRevealController 库导致了该问题。我重新设计了它在 AppDelegate 中的设置方式并解决了问题,尽管它有点“hacky”。我将“之前”和“之后”配置放在下面:
初始设置是:
- 配置 PKRevealController
- 配置 NavController 并添加 rootView
- 设置 pkreveal 前 View = navController
- 将显示 Controller 添加到窗口作为窗口 Root View
解决办法是
- 创建一个包含 NavController
- 执行上述步骤 1-3
- 将 pkrevealcontroller 添加到包含的 navController
- 将包含导航 Controller 的导航栏设置为隐藏
- 将包含导航 Controller 作为 Root View 添加到窗口
最佳答案
如果它的导航 Controller 比您可以在每个 View Controller 的 viewdidload 中使用它:
if ([self respondsToSelector:@selector(edgesForExtendedLayout)]) {
self.edgesForExtendedLayout = UIRectEdgeNone;
}
关于objective-c - ios7 PresentViewController 将 navBar 从新的 64px 栏恢复为旧的 44px 版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19322047/