'How to record video only in portrait in iOS but not in landscape?
I want to allow user to record a video only in portrait mode(orientation) and restrict the user to record in landscape. I'm using UIImagePickerController and I couldn't find any orientation options in it. could anyone help me out in this?
Solution 1:[1]
Write below code in AppDelegate:
func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
guard let mainController = navigationController else { return UIInterfaceOrientationMask.all }
if ((mainController.visibleViewController as? CameraVC) != nil) == false {
//This VC should support only Portrait Mode.
return UIInterfaceOrientationMask.portrait
} else {
//Else support All Modes.
return UIInterfaceOrientationMask.all
}
}
And It will Restrict Your "CameraVC" to Rotate in landscape Mode.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Kudos |
