简体   繁体   English

iPhone相机覆盖问题

[英]iPhone Camera Overlay issue

I am using Custom Overlay for camera in my iPhone app,I have followed this tutorial. 我在iPhone应用程序中使用相机的自定义叠加层,我已经按照教程进行操作。 My problem is-the overlay comes before the shutter opens,means on the shutter users can see the overlay items(buttons,image etc) 我的问题是-覆盖物在快门打开之前就出现了,意味着快门用户可以看到覆盖物(按钮,图像等)

I have tried with a timer,to delay the overlay appearance for the time of shutter opening animation,but that is not a right way. 我尝试过使用计时器,以在快门打开动画的时间上延迟叠加外观,但这不是正确的方法。

Any better idea? 有更好的主意吗?

-(void)onShowCam
{
   NSLog(@"sdadas");

    overlay = [[CustomOverlayView alloc]
           initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGTH)];

    overlay.delegate = self;

   .....

Try to use this 尝试使用这个

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

On the iPad this problem doesn't exist, and the overlay view is behind the shutter animation by default. 在iPad上,此问题不存在,并且默认情况下,叠加视图位于快门动画之后。 But on the iPhone, the overlay appears at front. 但是在iPhone上,叠加层显示在前面。

I've found a solution that worked for me. 我找到了适合我的解决方案。

You have to set your overlay view as a subview in this method: 您必须使用此方法将叠加视图设置为子视图:

- (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 it helps 希望能帮助到你

Original source: http://www.alexcurylo.com/blog/2009/06/18/uiimagepickercontroller-in-3-0/ 原始来源: http//www.alexcurylo.com/blog/2009/06/18/uiimagepickercontroller-in-3-0/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM