簡體   English   中英

cameraOverlayView以上快門動畫

[英]cameraOverlayView above Shutter animation

我有一個透明的視圖,使用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];
}
}

在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/

除了已經在做的事情之外,您可能別無選擇。 如果iOS決定將疊加視圖放在快門上,則只需要使用它即可(除非您想冒被應用商店拒絕的風險)。

作為一種不完善的解決方法,您可以使用alpha = 0來啟動疊加層,然后一兩秒后將alpha設置為1。 但是沒有在“打開”之前出現快門的設定時間(我認為這取決於初始化相機硬件所需的時間),因此有時您的界面可能要等到很晚才出現,有時可能出現得太早。

在這里回答了類似的問題。 對我有用的(在iOS 6中)是在navigationController:willShowViewController:animated中設置cameraOverlayView。

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

從4.3.3版本開始,由於元素顯示在頂部,因此動畫被破壞,然后在動畫開始時捕捉到下面。 我已將其作為雷達提交: http : //openradar.appspot.com/radar?id=1204401

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM