【问题标题】:cameraOverlayView above Shutter animation快门动画上方的 cameraOverlayView
【发布时间】:2011-03-25 23:23:58
【问题描述】:

我有一个透明视图,上面使用 CoreGraphics 绘制了一个矩形。 当相机启动时,自定义叠加视图位于快门动画上方。 您看到的是标准相机快门,上面有自定义矩形。 如何让它在快门动画下方的正确位置?我查看了其他示例代码,但它适用于 OS 3.1,似乎没有什么不同。

这是我的代码:

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

【问题讨论】:

    标签: iphone objective-c ios uiimagepickercontroller


    【解决方案1】:

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

    希望对你有帮助

    原文出处: http://www.alexcurylo.com/blog/2009/06/18/uiimagepickercontroller-in-3-0/

    【讨论】:

      【解决方案2】:

      除了你已经在做的事情之外,你不能做任何其他事情;如果 iOS 决定将您的叠加视图放在快门上,您只需要忍受它(除非您想冒被应用商店拒绝的风险)。

      作为一种不完美的解决方法,您可以使用 alpha=0 开始叠加,然后在一两秒后将 alpha 设置为 1。但是在“打开”之前没有设置快门出现的时间段(我认为这取决于初始化相机硬件需要多长时间),因此有时您的界面可能要到很晚才会出现,有时可能会出现得太早。

      【讨论】:

      • 嗯。我喜欢你对变通的想法,但就像你指出的那样,它行不通。
      【解决方案3】:

      从 4.3.3 开始,快门动画被破坏,因为元素显示在顶部,然后在动画开始时捕捉到下方。我已将此作为雷达归档:http://openradar.appspot.com/radar?id=1204401

      【讨论】:

        【解决方案4】:

        我回答了一个类似的问题here。对我有用的(在 iOS 6 中)是在 navigationController:willShowViewController:animated 中设置 cameraOverlayView。

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

        【讨论】:

          猜你喜欢
          • 2018-09-03
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2011-03-09
          • 1970-01-01
          • 1970-01-01
          • 2017-08-08
          相关资源
          最近更新 更多