1

フルスクリーンカメラを開いたままにして、ボタンを追加する必要があるアプリを開発しています(右下)。グーグルで検索しましたが、健全な解決策が見つかりませんでした。前もって感謝します。良い一日を過ごしてください。 編集済み

    - (void) showCameraUI {
    [self startCameraControllerFromViewController: self
                                    usingDelegate: self];
}

- (BOOL) startCameraControllerFromViewController: (UIViewController*) controller
                                   usingDelegate: (id <UIImagePickerControllerDelegate,
                                                   UINavigationControllerDelegate>) delegate {


    if (([UIImagePickerController isSourceTypeAvailable:
          UIImagePickerControllerSourceTypeCamera] == NO)
        || (delegate == nil)
        || (controller == nil))
        return NO;

    NSLog(@"Start Camera Controller method...");
    UIImagePickerController *cameraUI = [[UIImagePickerController alloc] init];
    cameraUI.sourceType = UIImagePickerControllerSourceTypeCamera;

    // Displays a control that allows the user to choose picture or
    // movie capture, if both are available:
    cameraUI.mediaTypes =
    [UIImagePickerController availableMediaTypesForSourceType:
     UIImagePickerControllerSourceTypeCamera];

    // Hides the controls for moving & scaling pictures, or for
    // trimming movies. To instead show the controls, use YES.
    cameraUI.allowsEditing = NO;

    cameraUI.delegate = delegate;

    [controller presentModalViewController: cameraUI animated: YES];
    return YES;
}

PS:UINavigationControllerDelegate,UIImagePickerControllerDelegateヘッダーファイルにプロトコルとして追加しましたが、まだカメラが開いておらず、プロジェクトのデフォルトビューが表示されます。

4

1 に答える 1

2

次のようなカメラを使用して、単純に画像をキャプチャできます。コードで次のメソッドを使用しています:-

-(void)btnCemeraOpen
{
        UIImagePickerController * picker = [[UIImagePickerController alloc] init];
        picker.delegate = self;


        if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
        {       
                picker.sourceType = UIImagePickerControllerSourceTypeCamera;
                [self presentModalViewController:picker animated:YES];
        }
}

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    [self dismissModalViewControllerAnimated:YES];
    yourImageView.image = [info valueForKey:@"UIImagePickerControllerOriginalImage"];
    if(yourImageView==nil)
    {

    }
    else
    {
      //DO logic

    }

    return;
}   
于 2013-03-14T07:05:43.060 に答える