IOS 7 landscape landscape app cannot access photo library

I only have a landscape app, and whenever I access the photo library, the app will crash (because the UIImagePickerViewController trying to load in portrait mode). The app works great in iOS 5 and 6.

I get the following error,

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

 *** First throw call stack: (0x2ff7ae8b 0x3a2746c7 0x2ff7adcd 0x3277337d 0x3277a4c5 0x3277a47b 0x327795b3 0x326fff3d 0x326ffd19 0x326ff609 0x326ff467 0x3270c153 0x3270bbd3 0x327b7f67 0x327b7d83 0x327afdf3 0x327af279 0x327aefe9 0x327aef7d 0x32700533 0x32387f43 0x32383767 0x323835f9 0x3238300d 0x32382e1f 0x3237cb4d 0x2ff45f71 0x2ff438ff 0x2ff43c4b 0x2feae541 0x2feae323 0x34be52eb 0x327651e5 0x8c439 0x8c3c0) `libc++abi.dylib:` terminating with uncaught exception of type `NSException` 0x326fff3d 0x326ffd19 0x326ff609 0x326ff467 0x3270c153 0x3270bbd3 0x327b7f67 0x327b7d83 0x327afdf3 0x327af279 0x327aefe9 0x327aef7d 0x32700533 0x32387f43 0x32383767 0x323835f9 0x3238300d 0x32382e1f 0x3237cb4d 0x2ff45f71 0x2ff438ff 0x2ff43c4b 0x2feae541 0x2feae323 0x34be52eb 0x327651e5 0x8c439 0x8c3c0) *** First throw call stack: (0x2ff7ae8b 0x3a2746c7 0x2ff7adcd 0x3277337d 0x3277a4c5 0x3277a47b 0x327795b3 0x326fff3d 0x326ffd19 0x326ff609 0x326ff467 0x3270c153 0x3270bbd3 0x327b7f67 0x327b7d83 0x327afdf3 0x327af279 0x327aefe9 0x327aef7d 0x32700533 0x32387f43 0x32383767 0x323835f9 0x3238300d 0x32382e1f 0x3237cb4d 0x2ff45f71 0x2ff438ff 0x2ff43c4b 0x2feae541 0x2feae323 0x34be52eb 0x327651e5 0x8c439 0x8c3c0) `libc++abi.dylib:` terminating with uncaught exception of type `NSException` 

When I turn on portrait mode, everything works as usual, but I don’t want to turn on portrait mode. What is the workaround for this?

+4
source share
4 answers

Yes, I have a similar problem in the application

you can add portrait support to the application, but restrict all other views to landscape support, mode, then the image selector will work

UIImagePickerViewController only works in portrait mode

to restrict other views to landscape mode support only, override - (NSUInteger) supported by theInterfaceOrientations in your view controller.

 - (NSUInteger)supportedInterfaceOrientations{ return UIInterfaceOrientationMaskLandscape; } 
+8
source

Add the code snippet below to the appdelegate.m file. This will solve the problem.

  -(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) { return UIInterfaceOrientationMaskAll; } else { return UIInterfaceOrientationMaskAllButUpsideDown; } } 
+1
source

The CGAffineTransform UIImagePickerController property can be used to get the camera in the desired orientation. imagePicker.cameraViewTransform=CGAffineTransformRotate(yourimagePicker.cameraViewTransform, M_PI/2);

Alternatively, you can also use CGAffineTransformScale to apply a custom size to your camera.

0
source

You can just submit imagePicker with

 ImagePickerController *imagePickerController=[[ImagePickerController alloc]init]; imagePickerController.modalPresentationStyle = UIModalPresentationCurrentContext; 
0
source

All Articles