Xcode 7.3, iOS 9.3.1
I want to use two custom overlay views for when the user is about to take a picture and after while editing the picture. To change the overlay I would like to know if there is a callback method from the UIImagePickerControllerDelegate
that will let me know when the user starts editing the picture, or when the user has tapped the take picture button.
The only methods I know of are:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
I have looked here: UIImagePickerController with cameraOverlayView focusses when button in overlay is tapped, How to know I tap "taking photo button" with UIImagePicker and iOS - Taking A Picture After Button Tap in UIImagePickerController CustomOverlayView.
Or perhaps there is a way to get the tap event from the standard button by adding an observer.
Please help! Thanks in advance.
UIImagePickerControllerDelegate is quite poor but you can handle it by adding an observer:
Swift 3:
Objective-C:
Xcode 8.2.1, iOS10.2.1
Before implementing please read the solution for earlier version to understand the basics. Thanks! The problem was that some of the names for various subviews have changed from iOS 9.3.1 to iOS 10.2.1.
Here is the complete code (see below where to insert), that replaces "//Code goes here" below:
Xcode 7.3, iOS9.3.1
I had to get this working, so I spent a lot of time figuring this out.
The gist of it is, I drill down the view hierarchy after the
UIImagePickerController
was presented, looking forCMKShutterButton
and the retake button with a title of "Retake", then I attach a selector to the buttons' action, like so...Drop the code below into the completion block that is called after your image picker is presented:
Here is the complete code, that replaces "//Code goes here" above:
And here is the method I am attaching, which goes in the view controller that is presenting the image picker controller:
Hope this helps someone! Thanks.
you could use the
UINavigationControllerDelegate
that you also have to implement when usingUIImagePickerController
. implementing the delegate method[...]didShowViewController[...]
like thisproduces the following output (using the simulator, choosing
UIImagePickerControllerSourceTypePhotoLibrary
as thesourceType
and navigating like this: photo albums overview > specific album > editing specific photo):2016-04-08 00:19:36.882 ImagePicker[44578:4705834] PUUIAlbumListViewController
2016-04-08 00:19:41.341 ImagePicker[44578:4705834] PUUIMomentsGridViewController
2016-04-08 00:19:47.929 ImagePicker[44578:4705834] PUUIImageViewController
hope that helps!