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

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

概述我目前正在使用默认的UI ImagePickerController,并在拍摄照片后立即显示以下默认屏幕: 我的问题是,我如何能够使用自己的自定义UIViewController来查看结果图像(因此绕过此确认屏幕). 请注意,我不想使用自定义叠加层为自定义相机控件或照片库中的图像使用UIImagePicker,而只是跳过此屏幕并假设拍摄的照片是用户喜欢的. 谢谢! 尝试使用此代码将结果图像保持为相 我目前正在使用默认的UI ImagePickerController,并在拍摄照片后立即显示以下默认屏幕:

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

谢谢!

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

首先为UIImagevIEw创建IBOutlet.

@H_301_13@-(voID)imagePickerController:(UIImagePickerController *)pickerdIDFinishPickingMediawithInfo:(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 – 如何设置使用UIImagePickerController拍摄的照片进行查看/修改为自定义UIViewController?全部内容,希望文章能够帮你解决ios – 如何设置使用UIImagePickerController拍摄的照片进行查看/修改为自定义UIViewController?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1105095.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-28
下一篇 2022-05-28

发表评论

登录后才能评论

评论列表(0条)

保存