Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 7 Landscape only app can't access photo library

I have a landscape only app and whenever I access the Photo library , app would crash (because UIImagePickerViewController is trying to load in portrait mode). App works fine in iOS 5 and 6.

I'm getting following error,

Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and shouldAutorotate is returning 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`

When I enable portrait mode everything works as usual but I don't want to enable portrait mode. What is the workaround for this?

like image 494
Rukshan Avatar asked Sep 25 '13 07:09

Rukshan


2 Answers

yes, I have similar issue in an app

you can add Portrait mode support to app but limit all other views to only support landscape, mode, then image picker will work

UIImagePickerViewController only works on portrait mode

to restrict other views only support landscape mode, override - (NSUInteger)supportedInterfaceOrientations in your view controller

- (NSUInteger)supportedInterfaceOrientations{
    return UIInterfaceOrientationMaskLandscape;
}
like image 112
lanbo Avatar answered Oct 08 '22 11:10

lanbo


Add below code snippet in appdelegate.m file. This will resolve the above issue.

 -(NSUInteger)application:(UIApplication *)application 
supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
     if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
     {
         return UIInterfaceOrientationMaskAll;
     }
     else
     {
         return UIInterfaceOrientationMaskAllButUpsideDown;
     }
}
like image 1
Anooj VM Avatar answered Oct 08 '22 13:10

Anooj VM