【问题标题】:Removing UIImagePickerController from UINavigationController in a UIPopoverController从 UIPopoverController 中的 UINavigationController 中删除 UIImagePickerController
【发布时间】:2013-08-05 00:06:57
【问题描述】:

这在 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];

}

【问题讨论】:

  • 你登录过 ioNavController 看看它是否为 nil 吗?另外,当你展示一个视图控制器时,你应该使用 self.presentingViewController 访问它,而不是 parentViewController。
  • 你尝试过什么吗?请给一些反馈

标签: ios uinavigationcontroller uiimagepickercontroller uipopovercontroller


【解决方案1】:

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

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

如果有用或有帮助,请告诉我。

【讨论】:

    【解决方案2】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-08-14
      • 1970-01-01
      • 2012-05-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多