1

I am working on an iPhone app that makes use of the camera overlay view of the UIImagePickerController. However, the problem I am running into is that my overlay is still on the screen when the picture is taken and the preview screen pops up. This looks very weird (the picture is rotated, but not the overlay). So, I need to do one of two things, both of which are proving more difficult than I would have hoped:

  1. Remove the overlay when the preview screen is active
  2. Don't show the preview screen

I know that I can accomplish #2 by setting showsCameraControls = NO - however, I am not currently creating my own camera controls, I still want to use the default controls. It seems like a sledgehammer approach to say that I need to recreate a perfectly fine UI with a custom built interface just to get around the preview screen.

Tiffado
  • 452
  • 2
  • 10
  • 23

3 Answers3

1

It's possible to use showsCameraControls = YES; and avoid the overlay on the preview view. I had the same problem and could solve it by using NSNotificationCenter along with @"_UIImagePickerControllerUserDidCaptureItem" and @"_UIImagePickerControllerUserDidRejectItem".

When entering the preview view you can remove the overlay :) A working code example can be found here: https://stackoverflow.com/a/23899448/1933185

Community
  • 1
  • 1
jerik
  • 5,714
  • 8
  • 41
  • 80
1

I don't know still anyone following this issue but it's possible to popBack and then show/present another screen/overlay for the additional trim/crop/editting and when cancel back to folder with staying same scroll level.

Code snippet here:

where ever you want to show image picker

present(imagePicker, animated: true)

then at the finish of picking(this issue only happens pick video)

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {

    let mediaType = info[UIImagePickerController.InfoKey.mediaType] as! String

    if (mediaType == "public.image"){
        NSLog("%@", "got image")
    }else if (mediaType == "public.movie"){
        NSLog("%@", "got movie")

        // dismiss(animated: true)

        let trimView = storyBoard.instantiateViewController(withIdentifier: "TrimView") as! TrimViewController

        trimView.delegate = self
        trimView.modalPresentationStyle = .pageSheet

        imagePicker.popViewController(animated: false)
        imagePicker.present(trimView, animated: true)

    }

}

with adding some additional delegates or with compilation however you does, at cancel handler of TrimViewController do this for go back to last position of UIImagePickerController picking view

func didFinishTrim() {
    imagePicker.dismiss(animated: true)
}

hope helps!

Yadigar ZENGİN
  • 189
  • 1
  • 4
0

As far as I can tell, this is not possible without creating your own custom Image Picker using the AVFoundation. The best answers to this question are here

Community
  • 1
  • 1
Travis Weerts
  • 152
  • 1
  • 5