ios - 翻页时隐藏导航栏

标签 ios swift

我在导航 Controller 中使用 UIPageViewController。仅当用户触摸 View 时才会出现导航栏。现在我想在用户滑动并更改页面时隐藏导航栏。我怎么做?我尝试了下面的代码,但它似乎不起作用。

let currentViewController = self.pageViewController!.viewControllers![0]
let viewControllers = [currentViewController]
self.pageViewController!.setViewControllers(
  viewControllers,
  direction: .Forward,
  animated: true, completion: {
      done in self.navigationController?.setNavigationBarHidden(true, animated: false)
})

最佳答案

尝试将其放入用户滑动时到达的页面的 viewWillAppear 方法中

self.navigationController?.setNavigationBarHidden(true, animated: true)

关于ios - 翻页时隐藏导航栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37852850/

相关文章:

ios - 应用如何将帐户与应用内购买订阅绑定(bind)?

iphone - 常规/组 UITableViewCell 中的字符数

ios - 在 UIViewController 的 subview 上初始化 xib

ios - NSUserDefaults(套件名称 :) on iOS 9 and WatchOS 2 - not working?

iphone - 如何在 friend 的墙上张贴图片和文字

ios - 在 UITabController 中关闭 View Controller

ios - 应用程序(_ :url:options:) is never called

swift - 如果使用 Xcode 9 设置断点,为什么 pthread_cond_wait 会返回?

ios - 如何在 CloudKit 记录中搜索部分单词?

ios - iPhone 和 iPad 之间的不同行为