我的问题是,我如何能够使用自己的自定义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?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)