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];
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.