iPhone摄像头覆盖问题
在我的iPhone应用程序中,我正在使用相机的自定义覆盖图,我遵循了教程。 我的问题是,覆盖在快门打开之前出现,这意味着用户可以在快门上看到覆盖项按钮、图像等 我曾尝试使用计时器,将叠加外观延迟到快门打开动画的时间,但这不是正确的方法 还有更好的主意吗iPhone摄像头覆盖问题,iphone,ios,camera,overlay,Iphone,Ios,Camera,Overlay,在我的iPhone应用程序中,我正在使用相机的自定义覆盖图,我遵循了教程。 我的问题是,覆盖在快门打开之前出现,这意味着用户可以在快门上看到覆盖项按钮、图像等 我曾尝试使用计时器,将叠加外观延迟到快门打开动画的时间,但这不是正确的方法 还有更好的主意吗 -(void)onShowCam { NSLog(@"sdadas"); overlay = [[CustomOverlayView alloc] initWithFrame:CGRectMake(0, 0,
-(void)onShowCam
{
NSLog(@"sdadas");
overlay = [[CustomOverlayView alloc]
initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGTH)];
overlay.delegate = self;
.....
试着用这个
cameraOverlay=[[ImagePickerController alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGTH)];
imagePicker.sourceType=UIImagePickerControllerSourceTypeCamera;
imagePicker.delegate=self;
imagePicker.showsCameraControls=NO;
imagePicker.cameraFlashMode=UIImagePickerControllerCameraFlashModeOff;
[imagePicker setCameraOverlayView:cameraOverlay];
//Show camera
[self presentModalViewController:imagePicker animated:YES];
在iPad上,这个问题并不存在,默认情况下,叠加视图位于快门动画的后面。但在iPhone上,覆盖层显示在前端 我找到了一个适合我的解决方案 在此方法中,必须将覆盖视图设置为子视图:
- (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];
}
希望能有帮助
原始资料来源: