Answer the question
In order to leave comments, you need to log in
How to turn off rotation for one controller?
Given: two controllers, main and child. The main should always maintain portrait orientation, and the child should rotate when the phone is rotated. Also, the child controller must be translucent.
FirstViewController.swift
override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
return .portrait
}
override var shouldAutorotate: Bool {
return false
}
override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
return .allButUpsideDown
}
override var shouldAutorotate: Bool {
return true
}
let secondViewController = self.storyboard?.instantiateViewController(withIdentifier: "SecondViewController") as! SecondViewController
secondViewController.modalPresentationStyle = .custom
self.present(secondViewController, animated: true, completion: nil)
Answer the question
In order to leave comments, you need to log in
try to implement the preferredInterfaceOrientationForPresentation method for the first controller and return .portrait from there, it used to work))
func preferredInterfaceOrientationForPresentation() -> UIInterfaceOrientation {
return .portrait
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question