How to use UIImagePickerController in an application that only supports landscape orientation in iOS-6?

I am developing an application that only supports landscape orientation. It uses the UIImagePickerController to select images and / or videos from the library. The app works fine in iOS-5 or earlier, but it crashes when I try to present an image selection controller. After a failure, the following message appears:

* Application termination due to the uncaught exception "UIApplicationInvalidInterfaceOrientation", reason: "Supported orientations do not have a common orientation with the application, and shouldAutorotate returns YES"

+3
ios6 uiimagepickercontroller uiinterfaceorientation landscape
Oct 12
source share
2 answers

As @rocky said you need to add Potrait mode to your application in order to use UIImagePickerController like this

Supported Interface Orientation in Info.plist or add this to your delegate-only class.

 - (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{ return UIInterfaceOrientationMaskAll; } 

and Mr.Daniel Answer I found a nice solution for your application "Landscape Only", since you only need to support landscape for your application, you just need to add a category for UINavigationController , like this

 @implementation UINavigationController (LandscapeOnly) - (NSUInteger) supportedInterfaceOrientations{ return UIInterfaceOrientationMaskLandscape; } @end 

and add this to your viewControllers, it works for me.

+8
Dec 07
source share

From the UIImagePickerController documentation:

Important: the UIImagePickerController class only supports portrait mode. This class is intended to be used as is and does not support subclasses. The presentation hierarchy for this class is private and cannot be changed with one exception. You can assign a custom view to the cameraOverlayView property and use this view to provide additional information or to control the interaction between the camera interface and your code.

You will need to add portrait mode in the orientation of the support interface if you want to use this controller.

+2
Oct 20 2018-12-12T00:
source share



All Articles