Allow all orientations for only one view controller

I know this question has already been asked in here , here and. I tried all possible ways, but was not successful.

I am trying to develop an application in Swift (iOS 8), in which only one view controller can be viewed in all orientations of others only in portrait.

To do this, I turned on only the mode Portraitin Target-> General-> Device Orientation (because I want the application to work only in portrait mode, except for one view controller).

I added the code below to the view controller, which I want to use in all orientations:

override func supportedInterfaceOrientations() -> Int {
    return Int(UIInterfaceOrientationMask.All.rawValue)
}

override func preferredInterfaceOrientationForPresentation() -> UIInterfaceOrientation {
    return UIInterfaceOrientation.LandscapeLeft;
}

override func shouldAutorotate() -> Bool {
    return true;
}

But he could not rotate it in landscape mode.

+4
2

:

  • ViewController.swift, ( true , , false )

, :)

+2

, , viewWillAppear:

 let value = UIInterfaceOrientationMask.All.rawValue

 UIDevice.currentDevice().setValue(value, forKey: "orientation") 

Target- > General- > Orientation

0

All Articles