0

这在iOS6中有效,所以不确定问题是什么。

在我的 UINavigationController (ioNavController) 中,我向 UIImagePickerController 展示了以下内容:

UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.modalInPopover = YES;
imagePicker.modalPresentationStyle = UIModalPresentationCurrentContext;
[self presentViewController:imagePicker animated:NO  completion:^{  }]; 

在我的 UIImagePickerControllerDelegate (确实被调用)中,我有以下内容:

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {

    //This does not work
    [ioNavController dismissViewControllerAnimated:YES completion:^{ /* Cleanup if Needed */ }];

    //This does not work
    [[picker parentViewController] dismissViewControllerAnimated:YES completion:^{ /* Cleanup if Needed */ }];

    //This does not work
    [picker removeFromParentViewController];

    // This presents a new view on the Nav Controller. It shows the new view ontop of the ImagePicker. Image Picker View does not repond to touches. 
    [ioNavController pageToSelect:0];

}
4

2 回答 2

0

您的委托与调用 imagepicker 的控制器位于同一控制器中吗?调用的同一个控制器presentViewController应该调用下面的行,并且图像选择器将被正确删除。

[self dismissViewControllerAnimated:YES completion:nil]; //self here it's the same reference that called presentViewController

让我知道是否有效或有帮助。

于 2013-08-04T05:48:05.037 回答
0

当您使用此代码时, UIImagePickerController 将自行删除:

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)pPicker {
[pPicker dismissViewControllerAnimated:YES completition:NULL]; }
于 2015-02-22T19:31:40.287 回答