I'm creating an iPhone-only app using the latest version of Swift and Xcode, with 3 tabBar sections in the app, and in only one tab bar I want the user to have its screen fixed to landscape. I've tried almost all possible solutions I found on StackOverflow and some other websites, all not seeming to work(including this one: How to lock orientation of one view controller to portrait mode only in Swift). Anyone know why?
This is the view controller of the view that I want to be fixed in landscape orientation:
import UIKit
@objcMembers class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
let value = UIInterfaceOrientation.portrait.rawValue
UIDevice.current.setValue(value, forKey: "orientation")
themes()
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
}
//Some Code
///////////////////////////////////////
override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
return .portrait
}
override var shouldAutorotate: Bool {
return false
}
///////////////////////////////////////
}