CameraOverlayView higher shutter animation

I have a transparent view with a rectangle drawn on it using CoreGraphics. When the camera launches a custom overlay view above the shutter animation. What you see is a standard camera shutter with a custom rectangle above it. How do I get it to go in the right place, under the shutter animation? I looked at another sample code, but it is for OS 3.1 and does not seem to do anything differently.

Here is my code:

-(IBAction)cameraButton{ if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerCameraDeviceRear]){ UIImagePickerController *picker = [[UIImagePickerController alloc] init]; picker.delegate = self; picker.sourceType = UIImagePickerControllerSourceTypeCamera; //Add the OverlayView with the custom Rectangle CGRect overlayFrame = CGRectMake(0.0f, 0.0f, 320.0f, 480.0f); OverlayView *overlayView = [[OverlayView alloc]initWithFrame:overlayFrame]; picker.cameraOverlayView = overlayView; [overlayView release]; [self presentModalViewController:picker animated:YES]; [picker release]; } } 
+4
source share
4 answers

This problem does not exist on the iPad, and by default, the overlay view is behind the shutter animation. But on the iPhone, the overlay appears in front.

I found a solution that worked for me.

In this method, you should set your overlay view as a subitem:

 - (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated { if (!viewController) return; UIView* controllerViewHolder = viewController.view; UIView* controllerCameraView = [[controllerViewHolder subviews] objectAtIndex:0]; UIView* controllerPreview = [[controllerCameraView subviews] objectAtIndex:0]; [controllerCameraView insertSubview:self.overlayView aboveSubview:controllerPreview]; } 

Hope this helps

Source: http://www.alexcurylo.com/blog/2009/06/18/uiimagepickercontroller-in-3-0/

+2
source

You can do nothing else than what you are already doing; if iOS decides to place your overlay view on top of the shutter, you just need to live with it (if you don’t want to risk getting a rejection from the app store).

As an imperfect workaround, you can start your overlay with alpha = 0, and then set alpha 1 second or two later. But there is no set period of time when the shutter appears before β€œopening” (I think it depends on how long it takes to initialize the camera’s hardware), so sometimes your interface may appear until late and sometimes it may appear too early.

+1
source

As in 4.3.3, the shutter animation is broken because the elements are displayed on top and then clicked under the start of the animation. I filed this as a radar: http://openradar.appspot.com/radar?id=1204401

0
source

I answered a similar question here . What worked for me (in iOS 6) was setting the camera OverlayView in navigationController: willShowViewController: animated.

 - (void) navigationController:(UINavigationController*) navigationController willShowViewController:(UIViewController*) viewController animated:(BOOL) animated { self.imagePickerController.cameraOverlayView = ...; // your camera overlay view } 
0
source

Source: https://habr.com/ru/post/1345296/


All Articles