1

I have a UIImagePickerController that is used to upload images to a database. It loads photos from two sources, the camera and the camera roll. When I load the photo from the camera it allows me to take a photo and select if I want to retake the photo or use it. When I load the photos from the camera roll I can select what photo library I want to use but only get a tiled preview of all photos in the library. When I click on the tiled photo preview it gets loaded to the database automatically with no full preview. How can I make it so that when I load a photo from the camera roll it allows me to preview the image before using it in a similar fashion to how it loads from the camera? Here is the coe that I use to specify the UIImagePickerController type, data source and initial settings.

UIImagePickerController *imgPicker = [[UIImagePickerController alloc] init];
imgPicker.delegate = self;
imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

[self presentViewController:imgPicker animated:YES completion:nil];
0

2 Answers 2

2

You have two options:

  1. You can use the allowsEditing property, set it to YES and the final step will be a “preview” of the picked photo. Of course the user can move and scale the photo from that preview, so maybe this is not what you want.
  2. Code your own preview. It will be a simple view controller that you will push into the UIImagePickerController when the user chooses a photo from the gallery. The simplest solution will be just an UIImageView covering all the screen, and two buttons in the navigation bar to choose another photo or choose the previewed one.
0

Hey thanks for all the help! I ended up using the third party libraries described here: https://github.com/gekitz/GKImagePicker. The GKImagePicker libraries allow you to easily define an editable and scalable area in the same manner as the allowsEditing does.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.