質問

私は、次のコードを持っています:

SecondViewController *secondView = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];

[imagePicker setSourceType:UIImagePickerControllerSourceTypeCamera];
[imagePicker setCameraOverlayView:secondView.view];
[imagePicker setShowsCameraControls:NO];

[self presentModalViewController:imagePicker animated:YES];

私の質問は:どのように私は "SecondViewController" からModalViewControllerを消すことができます。

役に立ちましたか?

解決

あなたはimagePickerUIImagePickerControllerDelegate方法からsecondViewに次を呼び出す必要があります。

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    // process message
    [imagePicker dismissModalViewControllerAnimated:YES];
}

他のヒント

受け入れ答えは、もはやiOS7で動作しません。以下は、代わりに使用するメソッドです。

ここでも、この方法はUIImagePickerからUIImagePickerControllerDelegateで呼び出さなければならない。

-(void) imagePickerController:(UIImagePickerController *)picker
             didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    [[picker presentingViewController] dismissViewControllerAnimated:YES completion:NULL];

}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top