我是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];
我希望图像是屏幕的大小,并且与相机中捕获的比例/纵横比相同