2016-06-16 177 views
0

我在導航控制器內使用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

,當我加入這個功能,現在它的工作原理

func pageViewController(pageViewController: UIPageViewController, willTransitionToViewControllers pendingViewControllers: [UIViewController]) { 
     self.navigationController?.setNavigationBarHidden(true, animated: true) 
} 
0

嘗試把這個在刷卡

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

燁試圖用戶到達頁面的viewWillAppear中方法..不工作 –