19

I am struggling with a problem. I am capturing a video, and i had put an UIImageView with an UIImage in it as the UIImagePicker CameraOverLay. So when the user starts the camera in order to capture a video, he can see an overlay on the camera. When the user stops capturing, and is being moved to the "cancel or Retake" screen of the UIImagePicker, the cameraOverlayView is still visible.

any ideas on how to not display the overlay in the "retake or cancel" screen?

Raz
  • 2,633
  • 1
  • 24
  • 44

2 Answers2

31

Solved by signing up to NSNotificationCenter, and listening to @"_UIImagePickerControllerUserDidCaptureItem" and @"_UIImagePickerControllerUserDidRejectItem".

Raz
  • 2,633
  • 1
  • 24
  • 44
  • 2
    You saved my day! I knew it would be possible. Thanks a lot. I added a [code example](http://stackoverflow.com/a/23899448/1933185). – jerik May 27 '14 at 21:42
  • @Raz are these notifications are private APIs? have you submitted any app to iTunes that uses these notifications? does apple approved your app? – Bhushan B Jun 25 '15 at 14:02
  • @Bhushan, as far as I know they are not private API, and I have successfully submitted an app to the AppStore which utilizes these notifications. – Raz Jun 26 '15 at 18:34
  • 1
    @Raz thanks for this information, it helped me a lot. – Bhushan B Jun 28 '15 at 05:25
  • Didn't check it, but probably, since the notifications are broadcasted by the OS – Raz Feb 13 '17 at 18:30
6

For Swift 4, it is:

    NotificationCenter.default.addObserver(forName: NSNotification.Name(rawValue: "_UIImagePickerControllerUserDidCaptureItem"), object:nil, queue:nil, using: { note in
        print("camera did capture")
    })

    NotificationCenter.default.addObserver(forName: NSNotification.Name(rawValue: "_UIImagePickerControllerUserDidRejectItem"), object:nil, queue:nil, using: { note in
        print("user pressed Retake")
    })
Brittany
  • 266
  • 1
  • 3
  • 8