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.
You can check this Stack overflow question This may help you. i had same same issue in a previous project and this helped out me. try it
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.