tags:

views:

870

answers:

3

For a cutom camera overlay I need to find out, when the iris is opened, because my overlay will allways shown while the iris is close (and then animating to open).

Any ideas ?

A: 

You should already know when the camera is ready to take a picture. At least the way I use a custom camera overlay, I init the view with something like self.sourceType = UIImagePickerControllerSourceTypeCamera; and the other usual setup, and the camera is ready (or "iris is open") at that point.

In summary, if one is using a custom camera overlay the way I am used to using it, one will know when the iris is open because it is under your control.

mikestew
This isn't answering his question. His problem is that his overlay is visible during the iris animation and he wants to show something different on the overlay only once the animation is complete. You don't have any control over how long the iPhone will take to present the camera controller and open the iris; you only know when you asked the view controller to start that process.
ddoughty
Answered it as best I could parse it. :-) My overlay does exactly that: only shows up once the animation is complete. In fact, looking at the debug version on my phone right now, there is a brief (almost undetectable had I not been looking for it) moment when the old overlay is shown after animation and before the modified overlay is displayed. The the overlay is never displayed on top of the animation. If the OP wants to follow up and confirm that is the desired behavior, I can dig out the code and post the sequence I'm using.
mikestew
Irrespective of the questioner, I'm interested in your code. :-) You seem to be implying that you have two overlays, but where/when are you changing from one to the other? My other question is with your self.sourceType line, which implies that you're subclassing the picker, but maybe that was just shorthand in your answer?The code I've seen and used follows this theme:a) create a custom viewb) create the pickerc) add the view as the overlay for the pickerd) set the sourceType of the pickere) present the pickerWhen you do that, you see the iris open over your custom view.
ddoughty
+3  A: 

You can listen for the PLCameraViewIrisAnimationDidEndNotification notification. Since this is not officially documented, you might be in violation of the Apple TOS, but I think so long as you write your code so that it's defensive against the possibility that the name or contract of this notification might change (so in the future you might not get the event) you'll probably be ok. In other words, use a timer or other technique to ensure that the thing you want done when the iris is open will definitely happen eventually even if you never get the notification...

Trivial example without the defensive programming. (Of course, you can register an interest only for this specific notification as well, see the docs for the notification center.)

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(notificationCallback:)
                                             name:nil
                                           object:nil
 ];

- (void) notificationCallback:(NSNotification *) notification {
     if ([[notification name] isEqualToString:@"PLCameraViewIrisAnimationDidEndNotification"]) {
         NSLog(@"Iris open");
         // we don't need to listen any more
         [[NSNotificationCenter defaultCenter] removeObserver:self];
     }
}
ddoughty
I've seen enough stuff quit working in the undocumented camera APIs between 2.x and 3.x, I'm not sure I'd rely on an undocumented call.
mikestew
A: 

hi! do you think is possible to skip the animation of the opening iris/shutter on the iphone?if it is possibile maybe it would fix a problem without solution till now: to me and lots of people over the word the shutter of the camera app don't open! so you can't take photos.Restore will not work...maybe it is hardware..and maybe not...what do you think?

Mikele