0

3 つの画面を持つアプリケーションを使用しています。

まずはホーム画面です。ボタンのあるホーム画面から、ユーザーは 2 番目の画面に移動します。ここには、写真を撮るためのボタンのみを備えたカメラ オーバーレイがあります。

ユーザーが写真を撮るとき、最後の画面に移動するボタンを押すことができます。しかし、彼が最後の画面からホームに移動し、次にオーバーレイの 2 番目の画面に移動すると、カメラは閉じられます。ボタンは彼が写真を撮ることができるように見えますが、彼はカメラを通して見ることができません.

ホーム画面に次のコードを使用して、オーバーレイを開始します。

if (self.imageView.isAnimating)
    self.imageView.stopAnimating;

if ([UIImagePickerController isSourceTypeAvailable:sourceType])
{
    [self.overlayViewController setupImagePicker:sourceType];
    [self presentModalViewController:self.overlayViewController.imagePickerController animated:YES];
}

overlayviewcontroller2 番目の画面とoverlayviewcontroller次のコードの場所は次のとおりです。

- (void)setupImagePicker:(UIImagePickerControllerSourceType)sourceType
{
    self.imagePickerController.sourceType = sourceType;

    if (sourceType == UIImagePickerControllerSourceTypeCamera)
    {
        self.imagePickerController.showsCameraControls = NO;

        if ([[self.imagePickerController.cameraOverlayView subviews] count] == 0)
        {
            CGRect overlayViewFrame = self.imagePickerController.cameraOverlayView.frame;
            CGRect newFrame = CGRectMake(0.0,
                                         CGRectGetHeight(overlayViewFrame) - self.view.frame.size.height - 10.0,
                                         CGRectGetWidth(overlayViewFrame),
                                         self.view.frame.size.height + 10.0);
            self.view.frame = newFrame;
            [self.imagePickerController.cameraOverlayView addSubview:self.view];
        }
    }
}

助けていただければ幸いです。

4

1 に答える 1

0

私は同じ問題に直面しており、それに対する解決策が1つあります。

私の解決策は以下の通りです

[self performSelector:@selector(setCameraOverlayView) withObject:Nil afterDelay:2];

以下の行を直接置く代わりに

[self.imagePickerController.cameraOverlayView addSubview:self.view];

inoverlayViewControllerの上記のメソッド

その行をセレクターメソッドに入れsetCameraOverlayViewます。

以下のように

-(void)setCameraOverlayView
{
    [imagePickerController.cameraOverlayView addSubview:self.view];
}

これで問題が解決します

ハッピーコーディング:)

編集

オーバーレイを初期化するには、以下のコードを使用し、オーバーレイの初期化関数も変更します

オーバーレイを開始するには

self.overlayViewController = [[OverlayViewController alloc] initWithNibName:@"OverlayViewController" bundle:nil images:self.finalData];

オーバーレイの init 関数

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil images:(NSArray *)imgArray
{
    if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]))
    {
        subCategories = imgArray;
        imagePickerController = [[UIImagePickerController alloc] init];
        imagePickerController.delegate = self;
        imagePickerController.navigationBarHidden = YES;
    }
    return self;
}

配列は必須ではないか、必要ではありません。オーバーレイを使用してさらに行う必要がある追加情報であり、省略できます。

ハッピーコーディング:)

于 2012-07-26T11:41:09.710 に答える