1

I am have 3 VC and in Xcode I enabled only Portrait mode but for one VC need enable Landscape Left & Right mode.

How I can enabled these orientation programmatically? I am try use this code but it's don't help me:

override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
            return .all
}
        
override open var shouldAutorotate: Bool {
            return true
}

Also did try use next way: Enable all screen orientation on xcode, and set for two VC only portrait mode, it's not bad BUT my VC have few subviews and when I hold phone in landscape orientation and then start program, VC have portrait orientation but other subview which I am create PROGRAMMATICALLY change self position on screen.

How I am can solve this problem?

Ice
  • 680
  • 1
  • 10
  • 23
  • 2
    Does this answer your question? [How to lock orientation of one view controller to portrait mode only in Swift](https://stackoverflow.com/questions/28938660/how-to-lock-orientation-of-one-view-controller-to-portrait-mode-only-in-swift) – meaning-matters Dec 02 '20 at 08:59
  • 1
    I am solved problem using next approach, enable all orientation inside Xcode, then for particular VC use "supportedInterfaceOrientations" only portrait mode then, shouldAutorotate set false, then I am set new position for my subview inside "viewWillAppear" and all work correct. Thanks for help. – Ice Dec 02 '20 at 10:15

0 Answers0