我正在使用UI
ImagePickerController来允许用户拍照.我想允许他后来编辑,但无论我做什么,我什么也没有.这是我的代码(我使用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);
我错过了什么吗?
编辑:
我已经遵循教程,我正在使用矩形屏幕,但是如果我平移或缩放,只要抬起手指就可以回到中央.是否可以从照片应用程序到这个屏幕?
解决方法
当使用UIImagePickerController的delegate -imagePickerController:didFinishPickingMediaWithInfo:时,我们使用
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
该代码将始终返回原始图像,即使编辑为ON.
尝试使用
UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage];
如果编辑为ON,则返回编辑后的图像.
希望这可以帮助.