*My view is in land scape mode i am saving image and i want that image back for that i my code is below and i am geting error "Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES'" * what can i do for iphone?
`- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
[self dismissModalViewControllerAnimated:YES];
[picker release];
}
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info {
[picker dismissModalViewControllerAnimated:NO];
imageDoodle.image = [info objectForKey:@"UIImagePickerControllerMediaMetadata"];
}
-(IBAction)loadfromalbumclicked:(id)sender
{
UIImagePickerController * picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing=NO;
picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
// self.modalTransitionStyle=UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:picker animated:YES];
}
-(IBAction)savePrint{
//Save image to iOS Photo Library
UIImageWriteToSavedPhotosAlbum(imageDoodle.image, nil, nil, nil);
//Create message to explain image is saved to Photos app library
UIAlertView *savedAlert = [[UIAlertView alloc] initWithTitle:@"Saved"
message:@"Your picture has been saved to the photo library, view it in the
Photos app." delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
//Display message alert
[savedAlert show];
}`
try setting shouldAutoRotate to NO and see if it works. You can use shouldAutoRotate and supportedInterfaceOrientations methods in iOS 6.0 or later, instead of the (deprecated) shouldAutoRotateToInterfaceOrientation method.
This error is thrown if there's a mismatch between the supported interface orientations in the plist and the ones returned by - (NSUInteger)supportedInterfaceOrientations
You supporting only limited orientations either landscape or portrait. But you calling different orientation in your view controller. You can see the following image with supported Orientation. It support only landscape right and landscape left.So if i call portrait it will show the error as like you.
- default orientation is set to AutoRotation >>> it works. - default orientation is set to Landscape left >>> it crashes when showing it. Alright then just to confirm that if you use that same small project into 2020.1.0b12, the Video Ad works a charm then the mentioned error doesn't occur at all.
try setting shouldAutoRotate to NO and see if it works.
You can use shouldAutoRotate and supportedInterfaceOrientations methods in iOS 6.0 or later, instead of the (deprecated) shouldAutoRotateToInterfaceOrientation method.
Something like this -
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskAll;
}
- (BOOL) shouldAutorotate {
return YES;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
return UIInterfaceOrientationPortrait;
}
You supporting only limited orientations either landscape or portrait. But you calling different orientation in your view controller.
You can see the following image with supported Orientation. It support only landscape right and landscape left.So if i call portrait it will show the error as like you. So if you want to support both orientation then change it in the summary.
See this answer for more detail. Hope it helps.
EDIT
So you have to put this code in your viewcontroller
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With