How can I enable rotation of screen programmatically in Swift?

327 Views Asked by At

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?

0

There are 0 best solutions below