开发者

Camera Shutter shows up in front of custom UIView?

I have a custom UIView that I have created to display my custom buttons and toolBar. When I first called for it to show, the bar is on top of the Shutter (which is good). But after the camera is loaded, the shutter comes in front of it, then opens.

If you look at the native camera.app, it doesn't do this. The toolbar stays there the whole time. Here is my code:

// .h

UIImagePickerController *theCamera;
@property (nonatomic, retain) UIImagePickerController *theCamera;


// .m

theCamera = [[UIImagePickerController alloc] init];
theCamera.delegate = self;
theCamera.sourceType = UIImagePickerControllerSourceTypeCamera;
theCamera.showsCameraControls = NO;
theCamera.toolbar.alpha = 0;
theCamera.navigationBarHidden = YES;
theCamera.toolbarHidden = YES;
theCamera.wantsFullScreenLayout = YES;
theCamera.cameraViewTransform = CGAffineTransformMakeScale(1.25, 1.25);

UIImageView *tabBarBack = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"tab_bar_back.png"]];
tabBarBack.frame = CGRectMake(0, 422, 320, 58);
[customView addSubview:tabBarBack];

theCamera.cameraOverlayView = customView;
[self presentModalViewController:theCamera an开发者_高级运维imated:YES];

Obviously there are more buttons I add to the customView, but you get the concept.


Subscribe to:

AVCaptureSessionDidStartRunningNotification

This is when the iris open animation begins. If you add a cameraOverlayView during this time, it will be properly covered up by the iris. It is posted at the same time as that PL… private notification. This is a documented approach that does not risk app rejection.


AFAIK there is no direct way to do this. If you use cameraOverlay, you will get shutter for the complete screen.
How ever there are some alternate methods (playing around with the view hierarchy) that will help you in making your preview screen as parent view. I am not sure if this approach is correct as per app store guidelines.
have a look at Hide/Show iPhone Camera Iris/Shutter animation for better understanding on how to achieve this.


On iOS 6+, if you've added your controller as the delegate for the UIImagePickerController, this code should ensure that the shutter stays behind your cameraOverlayView:

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

I haven't tested on versions of iOS prior to iOS 6 though.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜