从UIPopoverController中的UINavigationController中删除UIImagePickerController

时间:2013-08-04 00:20:05

标签: ios uinavigationcontroller uiimagepickercontroller uipopovercontroller

这适用于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];

}

2 个答案:

答案 0 :(得分:0)

您的委托是否在调用imagepicker的同一个控制器中?调用presentViewController的同一个控制器应该调用下面的行,并且将正确删除imagepicker。

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

告诉我工作或帮助。

答案 1 :(得分:0)

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

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)pPicker {
[pPicker dismissViewControllerAnimated:YES completition:NULL]; }