objective-c - ios7 PresentViewController 将 navBar 从新的 64px 栏恢复为旧的 44px 版本

标签 objective-c ios7 statusbar navbar

我有一个仅支持 ios7+ 的应用程序 导航栏设置使用状态栏下方显示的新 64 像素高栏。应用程序启动时如下所示:

enter image description here

如果我执行任何类型的“presentViewController”,当我关闭 View 时,导航栏会移回到 44px 高度,并且仍然出现在状态栏下方,这反过来又会使 View 的所有内容也向上移动。看起来像这样:

enter image description here

无论我是呈现我自己的 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”。我将“之前”和“之后”配置放在下面:

初始设置是:

  1. 配置 PKRevealController
  2. 配置 NavController 并添加 rootView
  3. 设置 pkreveal 前 View = navController
  4. 将显示 Controller 添加到窗口作为窗口 Root View

解决办法是

  1. 创建一个包含 NavController
  2. 执行上述步骤 1-3
  3. 将 pkrevealcontroller 添加到包含的 navController
  4. 将包含导航 Controller 的导航栏设置为隐藏
  5. 将包含导航 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/

相关文章:

iphone - 在 Objective-C iOS iPhone 等中将英国邮政编码转换为 Lat/Lng

iphone - RestKit - 向所有请求附加参数

ios - 将数字 0 - 59 添加到 NSMutableArray 以显示在 pickerView 中

ios - 为什么在 dealloc 发生在另一个线程上时尝试创建对 self 的弱引用时我会崩溃?

android - 状态栏通知自动启动 Activity

ios - SKColor clearColor 返回黑色?

iphone - 在 iOS 7 中为 UITableViewCell 使用背景 View 覆盖默认删除按钮

ios7 - iOS : More tab crashes on my subclassed UITabBarController on iOS 7. 1

ios - Swift iOS -SplitViewController 不会让我隐藏 StatusBar?

ios - 通话中状态栏将 UIPageViewController 内容 View 向下推