我可以使用现有的 UIPopoverController 和 UINavigationController 来显示 UIImagePickerController 吗?
我已经尝试了很多,但打开 UIImagePickerController 的唯一方法是关闭现有的 Popover 并打开一个新的。但我想将现有的与我的 UINavigationController 一起使用。
我的 iPad 应用程序有一些具有不同操作(在弹出窗口中)的按钮 - 如果用户选择“图像”,则还有另一个带有“来自现有图像”或“来自相机”的 View Controller - 如果我使用“现有图像” "我想在我现有的 Popover Controller 中打开 Photolibrary(因为当用户选择一个图像时,我想转到我的 UINavigationController 中的下一个 ViewController)
Atm 我在这里打开我的弹出窗口:
var popoverAddItems = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("popoverAddItems") as PopoverAddItemsViewController
var navigationPopover:UINavigationController!
var popover:UIPopoverController!
...
navigationPopover = UINavigationController(rootViewController: popoverAddItems)
popover = UIPopoverController(contentViewController: navigationPopover)
popover.popoverContentSize = CGSizeMake(320,120)
popover.presentPopoverFromRect(currentCell.LabelCellTitle.frame, inView: currentCell.LabelCellTitle.superview!, permittedArrowDirections: UIPopoverArrowDirection.Left, animated: true)
好的,现在我在我的 popoverAddItems ViewController 上,但是我怎么才能到这里,在这个 UINavigationController 中添加一个照片库?
所以我可以在关闭现有 Popover 时使用它:
var imagePickerViewController = PopoverImagePickerViewController()
imagePickerViewController.modalPresentationStyle = UIModalPresentationStyle.Popover
popover = UIPopoverController(contentViewController: imagePickerViewController)
popover.popoverContentSize = CGSizeMake(320,120)
popover.presentPopoverFromRect(currentCell.LabelCellTitle.frame, inView: currentCell.LabelCellTitle.superview!, permittedArrowDirections: UIPopoverArrowDirection.Left, animated: true)
有什么想法吗?任何帮助将不胜感激
最佳答案
要在弹出框内显示一个 UIImagePickerController(在您的例子中是一个 UIPopoverController 内的一个 UINavigationController),请在您的“showImagePicker:”例程中使用以下代码:
UIImagePickerController* imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.delegate = self;
imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; // Use your type here
imagePickerController.modalInPopover = YES;
imagePickerController.modalPresentationStyle = UIModalPresentationCurrentContext;
[self.navigationController presentViewController:imagePickerController animated:YES completion:NULL];
当您从 UINavigationControllers viewController 层次结构中调用它时,一切正常。如果您从其他地方调用它,请确保您使用 UIPopoverController 中使用的 UINavigationController 项来呈现 UIImagePickerController。
关于ios - 我可以将现有的 Popover 用于 UIImagePickerController 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25729182/