I am presenting UIImagePickerController
from the view controller. Its getting the following crash report only in iOS 6 but not getting in iOS 7.
*** Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'preferredInterfaceOrientationForPresentation must return a supported interface orientation!'
I am getting this crash only when presenting the UIImagePickerController
.
My app supports Portrait orientation so i am using the following code
-(BOOL)shouldAutorotate {
return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
if(UIInterfaceOrientationIsPortrait(toInterfaceOrientation))
return YES;
return NO;
}
-(NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;
}
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown);
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
return self.interfaceOrientation;
}
But only one page will support both portrait and landscape orientation so i enabled all orientations in info.plist
can any one pls help me that how to fix this crash.