1

小さなポップアップサブビューを開こうとしていますUIImagePickerControllerSourceTypeCameraが、これを試すたびにフルスクリーンカメラになります...カメラを使用しようとしたのはこれが初めてです開発者サイトのすべてのドキュメントを読みましたそして、自分がやりたいことを行う方法を説明するものを見つけることができません。

以下は私のstartCameraメソッドで、サブビューを作成し、cameraViewを作成してcameraViewを小さなサブビューに追加し、それをメインのUIViewにロードします....ただし、上記のように、毎回フルスクリーンになります:(

この cameraView を小さなポップアップ ビューのように見せるための助けをいただければ幸いです。

#pragma StartCamera
- (IBAction)startCamera:(id)sender {

    if (isCameraViewLoaded == NO) {
        // Load View for camera
        cameraView = [[UIView alloc] initWithFrame:CGRectMake(100.0, 100.0, 200.0, 100.0)];
        cameraView.backgroundColor = [UIColor greenColor];


        // imagepicker stuff
        // check for rear facing camera to continue
        if( [UIImagePickerController isCameraDeviceAvailable:UIImagePickerControllerCameraDeviceRear])
        {
            // load imagePickController into subview
           UIImagePickerController *imagePickController=[[UIImagePickerController alloc]init];
            imagePickController.sourceType=UIImagePickerControllerSourceTypeCamera;
            imagePickController.delegate=self;
            imagePickController.allowsEditing=TRUE;
            imagePickController.modalPresentationStyle = UIModalPresentationCurrentContext;
            [cameraView addSubview:imagePickController.view];
        }
        else {
            // if there is no camera on the device give warning
            UIAlertView *noCameraAlert = [[UIAlertView alloc] initWithTitle:@"Incompatible Device" message:@"Sorry, This feature requiers a rear facing camera" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];

            [noCameraAlert show];
        }

        // pass camera View to mainview
        [self.view addSubview:cameraView];
        isCameraViewLoaded = YES;
    }else{
        [cameraView removeFromSuperview];
        isCameraViewLoaded = NO;
    }

}
4

0 に答える 0