Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
333 views
in Technique[技术] by (71.8m points)

ios - UIImagePickerController AllowsEditing not working

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.

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);

Am I missing something?

EDIT:

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?

Image from the photos application

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.

Try using

UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage];

This will return the edited image if editing is ON.

Hope this helps.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...