ios – 如何设置使用UIImagePickerController拍摄的照片进行查看/修改为自定义UIViewController?

我目前正在使用认的UI ImagePickerController,并在拍摄照片后立即显示以下认屏幕:

我的问题是,我如何能够使用自己的自定义UIViewController来查看结果图像(因此绕过此确认屏幕).
请注意,我不想使用自定义叠加层为自定义相机控件或照片库中的图像使用UIImagePicker,而只是跳过此屏幕并假设拍摄的照片是用户喜欢的.

谢谢!

解决方法

尝试使用此代码将结果图像保持为相同大小:

首先为UIImageview创建IBOutlet.

-(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,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;
}

相关文章

当我们远离最新的 iOS 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...