how to use UIImagePickerController in an app which support Landscape orientation only in iOS-6?
Asked Answered
S

2

3

I am developing an app which supports Landscape orientation only. It uses an UIImagePickerController to pick images and/or videos from the library. App is functioning fine in iOS-5 or before but it gets crashed when I try to present image picker controller.It gives the following message after crashing:

* Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES'

Subclavian answered 12/10, 2012 at 13:7 Comment(1)
look at #20468835Joke
H
8

As @rocky said you have to add Potrait mode to your application to use UIImagePickerController Like this

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

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

and from Mr.Daniel's Answer i found a nice solution for your Landscape only App, as you need to support only landscape to 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.

Hetzel answered 7/12, 2012 at 12:22 Comment(4)
Did you know if still works for iOS 7? I try to do this, but UIImagePickerCtrler does not show in Landscape mode.Lumberyard
i have not tested that in iOS 7 so far.. will let you know asap @NorbertoBenavidesHetzel
@BetoBens Kindly take a look at this link Image Picker in Landscape App, Might help youHetzel
Thanks a lot @Bala, but if I don't misunderstand, the answer makes a UIImagePicker subclass and Apple does not recommend. I decide to use a popover in IPAD version of my app, but in iphone version I couldn't make landscape orientation yet.Lumberyard
R
2

From UIImagePickerController documentation:

Important: The UIImagePickerController class supports portrait mode only. This class is intended to be used as-is and does not support subclassing. The view hierarchy for this class is private and must not be modified, with one exception. You can assign a custom view to the cameraOverlayView property and use that view to present additional information or manage the interactions between the camera interface and your code.

You will have to add Portrait mode to your Support interface orientations if you want to use this controller.

Reprieve answered 20/10, 2012 at 0:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.