cameraOverlayView上面的快门动画 [英] cameraOverlayView above Shutter animation

查看:41
本文介绍了cameraOverlayView上面的快门动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a transparent view with a rectangle drawn onto it using CoreGraphics. When the camera launches the custom overlay view is above the shutter animation. What you see is the standard camera shutter with the custom rectangle above it. How do I get it to go in the right place, underneath the shutter animation? I've looked at other sample code but it's for OS 3.1 and doesn't seem to do anything differently.

这是我的代码:

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

推荐答案

在iPad上不存在此问题,并且默认情况下,叠加视图位于快门动画之后.但是在iPhone上,叠加层显示在前面.

On the iPad this problem doesn't exist, and the overlay view is behind the shutter animation by default. But on the iPhone, the overlay appears at front.

我找到了对我有用的解决方案.

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

希望有帮助

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

这篇关于cameraOverlayView上面的快门动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆