我在导航控制器中使用UIPageViewController。导航栏仅在用户触摸视图时显示。现在我想在用户滑动并更改页面时隐藏导航栏。我怎么做?我尝试了下面的代码,但它似乎没有用。
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)
})
答案 0 :(得分:0)
尝试将其放入用户在滑动时到达的页面的viewWillAppear方法
self.navigationController?.setNavigationBarHidden(true, animated: true)
答案 1 :(得分:0)
我添加了此功能,现在可以正常使用
func pageViewController(pageViewController: UIPageViewController, willTransitionToViewControllers pendingViewControllers: [UIViewController]) {
self.navigationController?.setNavigationBarHidden(true, animated: true)
}