iOS全屏相机覆盖

时间:2014-08-11 22:34:33

标签: objective-c iphone camera cgaffinetransform cameraoverlayview

我是objective-c的新手,并且一直在寻找这个问题的答案......

我正在创建一个照片共享应用程序,我希望相机是全屏的。我使用以下代码隐藏默认的相机覆盖并创建我自己的相机,并使相机全屏。在下一个屏幕上,我想再次显示捕获为全屏的图像,但图像正在侧面折叠。

设置相机覆盖:

-(void)loadCamera {
self.imagePicker = [[UIImagePickerController alloc]init];
self.imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
self.imagePicker.delegate = self;
self.imagePicker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
self.imagePicker.showsCameraControls = NO;

self.overlayIV = [[WAUCameraOverlayView alloc]initWithFrame:self.imagePicker.cameraOverlayView.frame];

[self.imagePicker.cameraOverlayView addSubview:self.overlayIV];

CGAffineTransform translate = CGAffineTransformMakeTranslation(0.0, 71.0); //This slots the preview exactly in the middle of the screen by moving it down 71 points
self.imagePicker.cameraViewTransform = translate;

CGAffineTransform scale = CGAffineTransformScale(translate, 1.333333, 1.333333);
self.imagePicker.cameraViewTransform = scale;

[self presentViewController:self.imagePicker animated:YES completion:nil];

}

以上代码效果很好,并使用我的自定义叠加层使相机全屏显示。然后,执行此代码块:

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
[self.overlayIV removeFromSuperview];
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];

}

我将“图像”传递到下一个屏幕并将其初始化为屏幕大小,但它会被拉伸...任何方式来保存/显示从全屏相机捕获的图像的确切比例和大小?

编辑:我用来显示图片的代码是:

UIImageView *capturedImageView =[[UIImageView alloc]initWithFrame:self.frame];
capturedImageView.image = aImage;
    capturedImageView.contentMode = UIViewContentModeScaleAspectFill;
    [self addSubview:capturedImageView];

我希望图像的大小与屏幕相同,并且与相机中拍摄的比率/宽高度相同

0 个答案:

没有答案