Вопрос

У меня есть следующий код:

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

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

[self presentModalViewController:imagePicker animated:YES];

Мой вопрос:Как я могу удалить ModalViewController из «SecondViewController»?

Это было полезно?

Решение

Вам необходимо позвонить по следующему номеру imagePicker из UIImagePickerControllerDelegate метод в 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