Search code examples
iosiphoneobjective-cios7uiimagepickercontroller

Orientation issue in Landscape mode while opening camera in iOS 7 in iPhone


I am having an app which is only in Landscape Mode. In my app I am opening the Camera from one of my views. It is working well for my iPad but on iPhone it crashes. It is working well in iOS 6 but the app crashes for iOS 7 and only for iPhone.

Below is my code.

if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{

    ipc=[[UIImagePickerController alloc] init ];
    ipc.delegate=self;
    ipc.sourceType=UIImagePickerControllerSourceTypeCamera;
    [self presentViewController:ipc animated:YES completion:nil];
} 
else {
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Desc" message:@"Camera capture is not supported in this device" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
    [alert show];
    [alert release];
}

How to solve this issue?

It crashes when I select to capture from camera. It doesn't crash from the above code but after that it crashes with below error.

I am getting this error:

Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES

And my app crashes.

My orientation code on this view.

-(BOOL)shouldAutorotate
{
    return YES;
}

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight ;
}

Solution

  • I found my solution from the link iOS7 iPad Landscape only app, using UIImagePickerController.

    It worked for me like a charm.

    Hope it help someone else also.

    Thanks for your help people.