Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES' [duplicate]

*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];
              }`
like image 224
virantporwal Avatar asked Jan 22 '13 10:01

virantporwal


People also ask

How to fix shouldautorotatetointerfaceorientation not working on iOS?

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.

What does the error-(nsuinteger) supportedinterfaceorientations mean?

This error is thrown if there's a mismatch between the supported interface orientations in the plist and the ones returned by - (NSUInteger)supportedInterfaceOrientations

What is the supported orientation of view controller?

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.

What is the default orientation for the video ad?

- 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.


2 Answers

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;
}
like image 100
vshall Avatar answered Sep 29 '22 00:09

vshall


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.

enter image description here

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;
 }
like image 21
vinothp Avatar answered Sep 29 '22 02:09

vinothp