I've noticed that in OS 3.1 you can add an overlay view to the image picker with
cameraOverlayView
However, I've also noticed that adding a view via this method also displays the view for the entire time the UIImagePicker is displayed, when I only want to show it during the preview stage.
Is there a way to make this only happen during preview? I don't want it to be there during the open shutter animation, or the screen that asks whether you want to use the image or retake.
I just wanted to show up another possibility without subview fiddling. There are system notifications for the changes in the CameraPicker. They are not documented either (as the subview structure). So they are also subject to change. BUT you get them.
You can register for them using no name:
We get some interesting (selfexplaining) notifications here:
You could use them, to trigger your overlayviews hidden state or anything else.
Actually, I was trying to do the same thing and I came across a much simpler of doing it via this blog post: http://www.alexcurylo.com/blog/2009/06/18/uiimagepickercontroller-in-3-0/
Since the UIImagePickerController can call a UINavigatorControllerDelegate, the method below gets called before the Image picker is displayed.
Here's the important code:
Hope that helps.
When you build up the picker add the overlay to the picker (picker.cameraOverlayView = myView).
The overlay will not be in the picture taken. It is just, like it says, an overlay view.
You can remove the overlay view before taking a picture (
takePicture
method) and add the view again inimagePickerController:didFinishPickingMediaWithInfo:
I've figured out a way for you to achieve the desired result though it's a bit... not so standard. :)
The idea is to rearrange a bit the order of the inner views in the structure
UIImagePickerController
uses.OK, so we create an
UIImagePickerController
object, initialize it and add an overlay view to it. May I have your attention please! TheUIView
object (UIImageView
in the example code) is hidden from the very beginning. Don't miss that. Finally we present the image picker controller as modal view controller. This code should be somewhere in yourapplicationDidFinishLaunching:
,viewWillAppear:
or similar appropriate about to launch methods.Before the overlay view (
anImageView
) is released aNSTimer
is created, initialized withanImageView
(NSTimer
userInfo
property) and scheduled right away. Here's the method it calls:The whole
NSTimer
thing is added to the flow to ensure that the reordering work around will happen exactly when theUIImagePickerController
will be totally ready for that.This is it. It works, it's not standard, it's rough and quick. Again feel free to optimize and make it 'righter' (oh please do, my aim was to show you the way).