I can't seem to lock certain view controllers in portrait mode. I have several view controllers that just consist of a basic view controller. the following code works to lock them in portrait:
//locking to portrate-----
override var shouldAutorotate : Bool {
if (UIDevice.current.orientation == UIDeviceOrientation.landscapeLeft ||
UIDevice.current.orientation == UIDeviceOrientation.landscapeRight ||
UIDevice.current.orientation == UIDeviceOrientation.unknown) {
return false
}
else {
return true
}
}
override var supportedInterfaceOrientations : UIInterfaceOrientationMask {
return [UIInterfaceOrientationMask.portrait ,UIInterfaceOrientationMask.portraitUpsideDown]
}
//finished locking-------
However i have some view controllers that are embedded into navigation controllers, and the above code does not work for these. I can't figure out the reasoning for this, any ideas?