iOS:How to call didFinishPickingMediaWithInfo after the photo is taken from camera - ios10

I want to call didFinishPickingMediaWithInfo without using the choose image button or i want to get the event when picture is successfully taken from camera in uiimagepickercontroller.

Related

Show custom alert for camera and gallery permission swift 3

May be this is duplicate question but I actually didn't find exact solution. I have camera and photo gallery collection view on the same screen.see this UI
When I land to this screen, I get two alerts: one for camera access and other for photo access. Can anyone tell me how to get rid of these native alerts and implement the custom one alert for both the permissions.
You can get the image when picking is done with imagePickerController
First, implement the UIImagePickerControllerDelegate
Second, create an instance and set the delegate
let imagePicker = UIImagePickerController()
imagePicker.delegate = self
Present the imagePicker with
present(imagePicker, animated: true, completion: nil)
And finally
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
let image = info[UIImagePickerControllerOriginalImage] as! UIImage
imagePicker.dismiss(animated: true, completion: nil)
}
Now you have the image.
Whenever you will be add permission details inside your applications <Your App Name>.plist. App will automatically show default alert message from your .plist privacy permissions String displaying there because permission message always display in default alert view so you can do one thing before access camera show yours custom alert then redirect to camera/gallery view.
Before accessing camera you can show like this(Example contain only)

Must I save the captured image to the Camera Roll when using UIImagePickerController with source type camera?

From the docs of UIImagePickerController:
When the user taps a button to pick a newly-captured or saved image or
movie, or cancels the operation, dismiss the image picker using your
delegate object. For newly-captured media, your delegate can then save
it to the Camera Roll on the device. For previously-saved media, your
delegate can then use the image data according to the purpose of your
app.
So this reads like I MUST save the captured image to the Camera Roll. Is this true? Reason for rejection if not done?
No, you do not need to save to Camera roll when UIImagePickerController is dismissed. I have done this in several apps.

grab image displayed on the UIImagePickerController without the overlay

I'm using UIImagePickerController with the camera as the sourceType. I am also drawing a custom overlay on the picker using the built-in overlay functionality(picker.overlay = myOverlay).
How can I get an UIImage of the camera, excluding my overlay?. I tried using UIGetScreenImage() but that captures my overlay as well.
[picker takePicture];

Library photos as source to UIImage

How to give images in photo library and camera as source to UIImage
/* On button click i want to save image */
myImage = /*What i have to give here to take camera or library images*/
UIImageWriteToSavedPhotosAlbum(myImage, self,
#selector(image:didFinishSavingWithError:contextInfo:), nil);
You need to use the UIImagePickerController object. It will present the modal view that allows either taking a picture or selecting an image from the device library. You should also become familiar with the UIImagePickerControllerDelegate protocol. With these two, it is easy to interact with both the camera and on-device library.

UIImageWriteToSavedPhotosAlbum not showing thumbnail in lower left corner

While the following code is saving the image I took from my application into the camera roll. I am trying to figure out how to update the thumbnail image that displays in the left corner next to the take image button when you first launch the camera to be the image that I saved. Shouldn't it always be the last image added to the camera roll? Here is how I am saving it:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
UIImage *originalImage = [info valueForKey:UIImagePickerControllerOriginalImage];
if (picker.sourceType == UIImagePickerControllerSourceTypeCamera) {
UIImageWriteToSavedPhotosAlbum(originalImage, nil, nil, nil);
}
}
I'm pretty sure there's nothing you can do to change that thumbnail; it's the Camera app's business what goes in there. At any rate, I think it is defined to contain a thumbnail of the last photo you took using the camera app.
I just tried this:
Launch Camera. Take a photo.
Launch Safari. Save an image from a page.
Launch Camera. The thumbnail is the photo I took, not the saved image.
I say either let it be or file a bug with Apple if you feel the behavior is incorrect.