ios – UIImagePickerController允许编辑不工作

前端之家收集整理的这篇文章主要介绍了ios – UIImagePickerController允许编辑不工作前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在使用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,则返回编辑后的图像.

希望这可以帮助.

原文链接:https://www.f2er.com/iOS/337439.html

猜你在找的iOS相关文章