如何设置UIImagePickerController的照片被查看/修改成一个自定义的UIViewController?

我正在使用默认的UIImagePickerController ,并立即拍摄照片后,显示以下默认屏幕:

在这里输入图像说明

我的问题是,我将如何能够使用我自己的自定义UIViewController来查看生成的图像 (并因此绕过此确认屏幕)。
请注意,对使用自定义相机控件或来自照片库的图像使用UIImagePicker的自定义叠加层感兴趣,而只是跳过此屏幕,并假定拍摄的照片是用户所喜欢的。

谢谢!

试试这个代码来保持你的合成图像大小相同:

首先为UIImageview创buildIBOutlet

 -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { NSString *mediaType = info[UIImagePickerControllerMediaType]; [self dismissViewControllerAnimated:YES completion:nil]; if ([mediaType isEqualToString:(NSString *)kUTTypeImage]) { OriginalImage=info[UIImagePickerControllerOriginalImage]; image = info[UIImagePickerControllerOriginalImage]; //---------- imageview.image = image; // additional method [self resizeImage]; //--------- if (_newMedia) UIImageWriteToSavedPhotosAlbum(image,self,@selector(image:finishedSavingWithError:contextInfo:),nil); } else if ([mediaType isEqualToString:(NSString *)kUTTypeMovie]) { // Code here to support video if enabled } } //---- Resize the original image ---------------------- -(void)resizeImage { UIImage *resizeImage = imageview.image; float width = 320; float height = 320; CGSize newSize = CGSizeMake(320,320); UIGraphicsBeginImageContextWithOptions(newSize,NO,0.0); CGRect rect = CGRectMake(0, 0, width, height); float widthRatio = resizeImage.size.width / width; float heightRatio = resizeImage.size.height / height; float divisor = widthRatio > heightRatio ? widthRatio : heightRatio; width = resizeImage.size.width / divisor; height = resizeImage.size.height / divisor; rect.size.width = width; rect.size.height = height; //indent in case of width or height difference float offset = (width - height) / 2; if (offset > 0) { rect.origin.y = offset; } else { rect.origin.x = -offset; } [resizeImage drawInRect: rect]; UIImage *smallImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); imageview.image = smallImage; imageview.contentMode = UIViewContentModeScaleAspectFit; } 

您可以使用叠加视图自定义图像拾取器视图控制器。

阅读这里的文档。

您设置一个新的视图,将其设置为相机覆盖图,告诉图像select器不显示自己的控件并显示select器。

在您的覆盖图代码中,您可以调用图像选取器视图控制器上的takePicture ,以便在准备就绪后最终拍摄图像。

苹果有一个这样的例子: https : //developer.apple.com/library/ios/samplecode/PhotoPicker/Introduction/Intro.html#//apple_ref/doc/uid/DTS40010196-Intro-DontLinkElementID_2

对于变换,可以使用cameraViewTransform属性来设置在拍摄图像时使用的变换。

拍照后,委托方法将被称为:

 - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info 

在这个方法中,你closures了imagePickerController。 你可以访问图像,所以你可以玩图像,可能显示在UIImageView。 所以代码会是这样的:

 - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { [self dismissViewControllerAnimated:YES completion:nil]; if (picker.sourceType == UIImagePickerControllerSourceTypeCamera) { //here you have access to the image UIImage *pickedImage = [info objectForKey:@"UIImagePickerControllerOriginalImage"]; //Create an instance of a view controller and show the UIImageView or do your stuff there. According to you business logic. } }