2013-10-13 1 views
0

J'essaie de prendre une photo avec mon application iPad mais quand je lance le UIImagePickerController, l'appareil photo montre l'image dans la mauvaise orientation.UIImagePicker mauvaise rotation lors de la prise de vue

Voici le code où j'ai appelé le UIImagePickerController:

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { 
    if (buttonIndex == 0 || buttonIndex == 1) { 
     // Initialization 
     self.imgPicker = [[UIImagePickerController alloc] init]; 
     self.imgPicker.allowsEditing = YES; 
     self.imgPicker.delegate = self; 

     // Chosing the source 
     if (buttonIndex == 0) { 
      self.imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; // Displayed in the good orientation 
     } 
     else { 
      self.imgPicker.sourceType = UIImagePickerControllerSourceTypeCamera; 
      self.imgPicker.showsCameraControls = YES; 
     } 

     // Popup pour la photo 
     self.imgPicker.allowsEditing = YES; 
     self.imgPicker.contentSizeForViewInPopover = CGSizeMake(1000, 700); 
     self.photoPopOver.delegate = self; 
     self.photoPopOver = [[UIPopoverController alloc] initWithContentViewController:self.imgPicker]; 
     [self.photoPopOver presentPopoverFromRect:self.photoBut.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; 
    } 
    else { 
     [self cancel]; 
    } 
} 

Choses à savoir: - Quand je mets le sourceType-UIImagePickerControllerSourceTypePhotoLibrary, la vue est affichée correctement - Lorsque la photo est prise, il est affiché dans la bonne rotation

Je ne sais pas s'il est utile de le dire, mais dans le contrôleur de vue parent, je ceci:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation { 
    return UIInterfaceOrientationIsLandscape(toInterfaceOrientation); 
} 

- (BOOL)shouldAutorotate { 
    return YES; 
} 

- (NSUInteger)supportedInterfaceOrientations { 
    return UIInterfaceOrientationMaskLandscape; 
} 

Comment puis-je résoudre ce problème? Merci beaucoup !

Répondre

0

// La solution est là pour corriger l'orientation de UIImage pris en utilisant UIImagePickerViewController ou Camera.

Voici un exemple pour résoudre le problème d'orientation check out here

une catégorie est définie pour résoudre le problème d'orientation dans l'IOS. cela se produit lorsque vous prenez l'image en mode Portrait en utilisant l'application "Appareil photo" dans le périphérique IOS, puis l'utilisez dans votre application via UIImagePickerViewController car l'orientation par défaut de la caméra est Landscape.

Questions connexes