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];
You have two options:
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.
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.
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.
Related
I have a view controller with UIImagePickerControllerDelegate and UINavigationControllerDelegate to pick photo.
I also want to make the same preview view when I picked photo done like the preview view when I taken photo done.
Have any suggestion? Thx!
You can get the UIImagePickerController to show the preview screen when choosing a photo if you set picker.allowsEditing to true. Be aware though that this will allow users to crop and reposition their photo in both the photo library and camera source types.
I have an UIImagePickerController and want to know, when a user changes from the back to front camera (and back)?
Is it possible to get this information?
As second part.
After taking a picture UIImagePickerController shows a preview with (Retake and Use Photo Buttons). Is it possible to detect when this view is shown?
You can write your own camera overlay view to have total control over the camera switching and preview behavior. Without a custom camera overlay view, I think you're limited to just receiving the user's final choice in the UIImagePickerControllerDelegate callback.
After taking a picture using the ImagePickerController and selecting "Use", I want the camera screen to appear again to continue taking more shots, how do I achieve this so I can keep taking shots without stopping? I am not using AVFoundation but ImagePickerController.
If you set showsCameraControls of your UIImagePickerController to NO and provide your own camera controls you can take multiple pictures after each other and dismiss the interface when you see fit.
I am implementing a flow where the user can either select a photo from their library or take a photo using the camera.
When presenting the UIImagePickerController modally I have to either go:
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
or
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
This means presenting a "scaffolding controller" where to user can pick either their Library or the Camera.
I see that most other apps with this kind of functionality go directly to the Camera controller, but displays a button for selecting from the library instead.
All examples/tutorials I can find, including Apple's PhotoPicker source, does this empty viewController where you pick from camera or library - but all apps I check does the 'direct to camera - with the option for going to library".
How do I add the photo library button option to the camera tool bar?
(app >= iOS 4.3)
Thanks for any help given.
According to this previous question
Enabling the photo library button on the UIImagePickerController
you can use cameraOverlayView and showsCameraControls to make the implementation.
-Vik
For this purpose I have used PhotoPicker by Apple.
I'm developing a camera application where I'd like to put some functions that are already present in the stock app. My problem is replicating the little square in the bottom left corner (in portrait mode) where the micro-thumbnail of the photo that the user has just taken is shown; then, when the user tap on it, the photo app should open, on the last photo saved in the camera roll.
I can load the thumbnail of the newest photo in camera roll with ALAssetsLibrary - I've access to it with [UIImage imageWithCGImage:[result thumbnail]] - but even if I have its ALAsset URL, I can't open the photo app. I'm trying to do it with:
[[UIApplication sharedApplication] openURL:result.defaultRepresentation.url];
But nothing happens.
I could display it internally in my app, with an additional UIView, but I think will be simpler and... smarter to use the official photo app!
Can anyone help me? Thank you in advance!
You may want to use the UIImagePickerController, as answered here: https://stackoverflow.com/a/11078182/883413