2017-03-04 265 views

回答

0

在您的视图控制器将这个:

override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) { 
    if UIDevice.current.orientation.isLandscape { 
     print("will turn to landscape") 
    } else { 
     print("will turn to portrait") 
     //print an alert box here 
     UIDevice.current.setValue(UIInterfaceOrientation.landscapeLe‌​ft.rawValue, forKey: "orientation") 
    } 
} 

来源:How to detect orientation change?

或者把这个需要在横向视图:

override func shouldAutorotate() -> Bool { 
    return false 
} 

override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask { 
    return UIInterfaceOrientationMask.landscape 
} 

但是这一个不能发布一个警报。

+0

@LijithVipin - portait被锁定意味着 –

+0

@ LiJithVipin我不明白你想说什么,你能详细说明一下吗? – paper1111

相关问题