ios - ipad UIImagePickerController 预览时和拍摄风景时的尺寸不同

标签 ios uiimagepickercontroller uipopover

我一直在阅读不同的答案,但无法解决这个问题:

在我的 iPad 应用程序(横向模式)上,我有一个 UIImagePickerController 来拍摄此选择器在 UIPopoverController 内显示的照片。

问题是预览时的图像尺寸与拍照后的图像尺寸不同

预览:

image on preview .

拍摄图像后:

taken pic

这是我设置选择器和 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/

相关文章:

iphone - 更平滑的慢速旋转 UIImage

ios - UIStackView() 与 UIStackView(frame : . 零) 初始化程序

uiimagepickercontroller - iOS 7 状态栏与 UIImagePickerController 上的相机控件重叠

ios - UIAlertController popoverPresentationController 错误 : Snapshotting a view that has not been rendered results in an empty snapshot

ios - 防止弹出框显示过度呈现的 View

c++ - 如何在 iOS 上编译 fftw3

objective-c - NSLog,如何为不同大小的字段生成固定宽度的输出?

iPhone - 从 UIWindow 启动 UIImagePickerController

ios - 使用 UIImagePickerController 选择视频时调用的事件

ios - 防止一次显示多个 UIPopover