How do I know if the "iris" animation has finished running UIImagePickerController?

Hey guys, I need some help ... I really can't find it on Google ...

I have a tabbed application that will display a UIImagePickerController on one of the tabs to get a snapshot from the camera ... I use the top view, but when the camera takes almost 3 seconds to "open" "irs" "(initial animation), my the overlay view is already visible above the closed diaphragm !!!

I need to check how to check if the iris is closed, so I can hide the overlay view.

I read a few posts about subclassing UIImagePickerController, but apple said we should not do this with UIImagePickerController ....

Who has a key? I'm really lost here ....

thanks

+4
source share
1 answer

Iris animation works according to the method of [UIImagePickerController viewDidAppear] . Apple scares UIImagePickerController subclasses for a variety of reasons, but if you need to add overlay finishes after the iris and are not ready to write your own Image Capture class with AVFoundation, I would like to do something like this:

If you are not alone, add a new subclass of UITabBarViewController with UIImagePickerController @property and delegates UIImagePickerControllerDelegate and UINavigationControllerDelegate

 @interface my_TabBarViewController : UITabBarController <UIImagePickerControllerDelegate, UINavigationControllerDelegate> @property (nonatomic, strong) UIImagePickerController *picker; 

In the implementation, add the initCamera method and call it in viewDidLoad

 - (void)initCamera { _picker = [[UIImagePickerController alloc] init]; _picker.sourceType = UIImagePickerControllerSourceTypeCamera; _picker.view.frame = CGRectMake(0.f, 20.f, 320.f, 499.f); _picker.navigationBarHidden = TRUE; _picker.delegate = self; _picker.cameraOverlayView = YourCameraOverlayView; [self.view addSubview:_picker.view]; [_picker viewDidAppear:FALSE]; [self.view sendSubviewToBack:_picker.view]; } 

Then, when an item on the tab bar of the cameraโ€™s view is displayed, show the camera using this method on your tab bar controller:

 - (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item { NSLog(@"tapped: %@", item.title); if ([item.title isEqualToString:@"Camera"]) { [self.view bringSubviewToFront:_picker.view]; } else { [self.view sendSubviewToBack:_picker.view]; } } 

Finally, in your UIImagePickerController delegate UIImagePickerController on the tab bar controller, clear the Image Picker and send the dictionary of information to your camera controller to process the image, however you need to:

 - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { [_picker.view removeFromSuperview]; yourCameraViewController *camVC = (yourCameraViewController*)[self.viewControllers objectAtIndex:1]; // Index 1 would just be the second tab, adjust accordingly [camVC imagePickerController:picker didFinishPickingMediaWithInfo:info]; [self initCamera]; } 

Call [self initCamera]; here will result in reinitializing the UIImagePickerController , which you may or may not want to do here. I would suggest that simply #import "my_TabBarViewController.h in your yourCameraViewController , and then you can grab a picker pointer in your UIImagePickerController UIImagePickerController by calling:

 my_TabBarViewController *tabBarVC = (my_TabBarViewController*)self.tabBarController; 

and yourCameraViewController release it and the tabBarVC message to restart UIImagePickerController when you need it.

0
source

All Articles