我正在尝试使用我的 iPad 应用程序拍照,但是当我启动 UIImagePickerController 时,相机以错误的方向显示图像。
这是我调用 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];
}
}
要知道的事情: - 当我设置为时sourceType
,UIImagePickerControllerSourceTypePhotoLibrary
视图显示正确 - 拍照时,它以良好的旋转显示
我不知道告诉它是否有用,但在父视图控制器中,我有这个:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
return UIInterfaceOrientationIsLandscape(toInterfaceOrientation);
}
- (BOOL)shouldAutorotate {
return YES;
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscape;
}
我该如何解决?非常感谢 !