0
votes
 //In AppDelegate.m, I am forcing every window to LandScapeRight.

  -(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{
return UIInterfaceOrientationMaskLandscapeRight;
   }

 //In ScanViewController.m, I am accessing camera and Image Library.

  @implementation ScanViewController
 -(void)viewDidLoad {
 [super viewDidLoad];
// Do any additional setup after loading the view.
 }
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
 }

- (NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskAll;
 }
//Select photo from iPhone Image Library.
- (IBAction)photoFromAlbum:(id)sender 
 {
UIImagePickerController *photoPicker = [[UIImagePickerController alloc] init];
photoPicker.delegate = self;
photoPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentViewController:photoPicker animated:YES completion:NULL];
 }
//Take photo from camera
- (IBAction)photoFromCamera:(id)sender 
 {
UIImagePickerController *photoPicker = [[UIImagePickerController alloc] init]; 
photoPicker.delegate = self;
photoPicker.sourceType = UIImagePickerControllerSourceTypeCamera; 
[self presentViewController:photoPicker animated:YES completion:NULL];
 }
//Save the Image
- (void)imagePickerController:(UIImagePickerController *)photoPicker    didFinishPickingMediaWithInfo:(NSDictionary *)info
{
self.saveButton.enabled = YES;
self.filterButton.enabled = YES;
originalImage = [info valueForKey:UIImagePickerControllerOriginalImage];
[self.selectedImageView setImage:originalImage];
[self dismissViewControllerAnimated:YES completion:nil];
}

Now, I am getting this error "PLUICameraViewController shouldAutorotate is returning YES". I am using iOS 8 and I want my application to work in landscape mode, but when I access "ScanViewController.m", then it can be both Landscape or portrait because I read that in iOS8, it is compulsory, when accessing camera to have portrait view. Any suggestions are more than welcome.

1

1 Answers

0
votes

UICameraViewController only supports portrait mode. From the Apple Documentation:

IMPORTANT

The UIImagePickerController class supports portrait mode only. This class is intended to be used as-is and does not support subclassing. The view hierarchy for this class is private and must not be modified, with one exception. You can assign a custom view to the cameraOverlayView property and use that view to present additional information or manage the interactions between the camera interface and your code.

So you should return UIInterfaceOrientationMaskPortrait on supportedInterfaceOrientations and you should also return NO on shouldAutorotate.

-(BOOL)shouldAutorotate
{
    return NO;
}

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait;
}