2017-03-04 91 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

相關問題