1
votes

When I try to capture an image in ios using UIImagePickerController, I do the following

  1. Check for camera access
  2. Present the image picker
  3. add logic in the delegate method - didFinishPickingMediaWithInfo.

However, after the image picker is presented, the user click on Camera Button. After that the image is loaded as preview with "Retake" and "Use Photo" as options. Only when I click on Use Photo does the didFinishPickingMediaWithInfo get invoked. I would like to get rid of the step for the user to confirm by clicking on Use Photo.

I would like to invoke didFinishPickingMediaWithInfo when the user clicks on the Camera Button.

Updated: A better to way to have more control over Camera is by using the AVFoundation.

1

1 Answers

1
votes

That's not supposed to happen using the UIImagePickerController. So you have two choices:

  • 1) Build your own Camera ViewController using a PreviewLayer etc. (clean solution) OR
  • 2) Listen for private API notifications, which will tell you when certain events happen.. You can just add yourself as an observer to all system notifications like this:

    [[NSNotifcationCenter defaultCenter] addObserver:self selector:@selector(notificationReceived:) name:nil object:nil]

To find out which notification is interesting to you. Then listen to that and take actions (dismiss the VC), when it occurs. Not sure how you would receive the image though. That would need more hackery with private APIs.. note that all of the second solution here might get your app rejected.