-1

I have an app whose root view controller is in the portrait mode. But I want to fix one of its child view controller to landscapeLeft. How can I realize this?

My project setting include both landscapeLeft and portrait orientations for the app.

In root view controller:

override var shouldAutorotate: Bool {
        return false
    }    
override var preferredInterfaceOrientationForPresentation: UIInterfaceOrientation
    {
        return .portrait
    }

In the child view controller:

    override var shouldAutorotate: Bool {
        return false
    }   
    override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
        return .landscapeLeft       
    }
    override var preferredInterfaceOrientationForPresentation: UIInterfaceOrientation
    {
        return .landscapeLeft
    }

But it seems that the child view controller is still fixed at the portrait mode, maybe dominated by the setting in the root view controller? If so, how should I adjust to realize my goal?

Hope some one can provide insights here. Just want to make sure I'm looking at the right place.

Thanks a lot!

Regards, Paul

PaulLian
  • 197
  • 1
  • 10
  • Possible duplicate of [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) – El Tomato Mar 27 '19 at 01:31

1 Answers1

0

Go in info.plist and under "supported interface orientations" delete everything except landscape (left home button) or landscape (right home button). Which ever you prefer.