Setzen Sie diese in Ihrem View-Controller:
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.landscapeLeft.rawValue, forKey: "orientation")
}
}
Quelle: How to detect orientation change?
Oder diese zur Ansicht gestellt, die in der Landschaft sein muss:
override func shouldAutorotate() -> Bool {
return false
}
override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
return UIInterfaceOrientationMask.landscape
}
Aber das kann man nicht veröffentlichen eine Warnung.
@LijithVipin - Portait ist gesperrt bedeutet –
@LijithVipin Ich verstehe nicht, was Sie versuchen zu sagen, können Sie erarbeiten? – paper1111