我一直在阅读不同的答案,但无法解决这个问题:
在我的 iPad 应用程序(横向模式)上,我有一个 UIImagePickerController 来拍摄此选择器在 UIPopoverController 内显示的照片。
问题是预览时的图像尺寸与拍照后的图像尺寸不同
预览:
.
拍摄图像后:
这是我设置选择器和 popOver 的代码:
BOOL hasCamera = [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera];
picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = hasCamera ? UIImagePickerControllerSourceTypeCamera : UIImagePickerControllerSourceTypePhotoLibrary;
picker.modalPresentationStyle = UIModalPresentationFullScreen;
picker.cameraDevice = UIImagePickerControllerCameraDeviceFront;
[picker setShowsCameraControls:FALSE];
self.companyPopOverController = [[[UIPopoverController alloc] initWithContentViewController:picker] autorelease];
self.companyPopOverController.passthroughViews=[NSArray arrayWithObject:self.view];
[self.companyPopOverController presentPopoverFromRect:CGRectMake(622, 534, 10, 10) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES];
并显示拍摄的照片:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *image=[info objectForKey:UIImagePickerControllerOriginalImage];
[self.picImage setImage:image];
[self.companyPopOverController dismissPopoverAnimated:YES];
self.imageTaken = YES;
}
那么如何使预览图像与实际拍摄的图像大小相同?
谢谢!
最佳答案
我发现您的示例图像有两个不同之处:大小和水平翻转。
大小差异可能是因为您设置了 picker.modalPresentationStyle = UIModalPresentationFullScreen;
但随后您在较小的弹出窗口中显示它。
我会尝试在没有弹出窗口的情况下呈现选择器,看看它是否有效。
此外,预览图像看起来有点扭曲。如果您使用缩放填充作为imageView的contentMode,那么我会将其更改为长宽比填充。
我不知道水平翻转可能来自哪里。
关于ios - ipad UIImagePickerController 预览时和拍摄风景时的尺寸不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17482674/