问题描述
我使用 UIImagePickerController 来允许用户拍照.我想让他/她事后编辑它,但是,无论我做什么,我都一无所获.
I am using UIImagePickerController to allow the user to take a picture. I want to allow him/her to edit it afterwards but, whatever I do, I get nothing.
这是我的代码(我使用的是 Xamarin):
Here is my code (I am using Xamarin):
UIImagePickerController imagePicker = new UIImagePickerController ();
// set our source to the camera
imagePicker.SourceType = UIImagePickerControllerSourceType.Camera;
// set what media types
//imagePicker.MediaTypes = UIImagePickerController.AvailableMediaTypes (UIImagePickerControllerSourceType.Camera);
// show the camera controls
imagePicker.ModalPresentationStyle = UIModalPresentationStyle.CurrentContext;
imagePicker.ShowsCameraControls = true;
imagePicker.AllowsEditing = true;
imagePicker.SetEditing (true,true);
imagePicker.PreferredContentSize = new SizeF(900,600);
imagePicker.CameraCaptureMode = UIImagePickerControllerCameraCaptureMode.Photo;
imagePicker.Title="taste.eat. image";
// attach the delegate
imagePicker.Delegate = new ImagePickerDelegate();
// show the picker
NavigationController.PresentViewController(imagePicker, true,null);
我错过了什么吗?
我已经按照教程操作,我正在使用矩形进入屏幕,但是如果我平移或缩放它,一旦我抬起手指,它就会回到中心.是否可以从照片应用程序进入此屏幕?
I have followed the tutorial and I am getting to the screen with the rectangle, but if i pan or zoom it just snaps back to the center once I lift my finger. Is it possible to get to this screen from the photos application?
推荐答案
当使用UIImagePickerController's delegate
方法 - imagePickerController:didFinishPickingMediaWithInfo:
,我们使用
When using UIImagePickerController's delegate
method - imagePickerController:didFinishPickingMediaWithInfo:
, we get the image using
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
此代码将始终返回原始图像,即使编辑处于打开状态.
This code will always return the original image, even if editing is ON.
尝试使用
UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage];
如果编辑打开,这将返回编辑后的图像.
This will return the edited image if editing is ON.
希望这会有所帮助.
这篇关于UIImagePickerController 允许编辑不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!