我從UIPageViewContoller類繼承了3個視圖控制器。他們兩個應該只有肖像方向和一個 - 所有的方向。我添加了這樣一段代碼:UIPageViewController:如何處理視圖控制器的不同方向?
override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
return self.currentStackVC.supportedInterfaceOrientations()
}
override func shouldAutorotate() -> Bool {
return self.currentStackVC.shouldAutorotate()
}
override func preferredInterfaceOrientationForPresentation() -> UIInterfaceOrientation {
return self.currentStackVC.preferredInterfaceOrientationForPresentation()
}
override func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransitionToSize(size, withTransitionCoordinator: coordinator)
}
其中currentStackVC是當前可見視圖控制器。 我也有我的視圖控制器這樣的代碼有一點不同的實現:
前兩個viewcontrollers(未來 - VC):
override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
return UIInterfaceOrientationMask.Portrait
}
override func shouldAutorotate() -> Bool {
return false
}
override func preferredInterfaceOrientationForPresentation() -> UIInterfaceOrientation {
return UIInterfaceOrientation.Portrait
}
末:
override func shouldAutorotate() -> Bool {
return true
}
override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
return UIInterfaceOrientationMask.All
}
override func preferredInterfaceOrientationForPresentation() -> UIInterfaceOrientation {
return UIInterfaceOrientation.Portrait
}
當我位於第三視圖控制器 - 我旋轉我的設備並應用新的方向。但不幸的是,它也適用於其他風險投資公司。系統在第一個和第二個VC中不要求shouldAutorotate()。 (正如我想的那樣,因爲每次只詢問當前的第三VC)。我去第二個VC(使用滑動),並且它也是橫向的。所以,我的問題是 - 如何處理Page VC中不同屏幕的不同方向?
在此先感謝
你設法解決這個問題? – Nil
不,我沒有。 – frankWhite