can i use an existing UIPopoverController with an UINavigationController to display an UIImagePickerController?
Ive tried so much, but the only way to open an UIImagePickerController is to close the existing Popover and open a new one. But i would like to use the existing with my UINavigationController.
I have some Buttons with different actions (in a popover) of my iPad Application - if the user selects "Image" there is another View Controller with "From existing Images" or "From Camera" - if i use "existing Images" i would like to open the Photolibrary in my existing Popover controller (because when the user select one Image, i would like to go to the next ViewController inside my UINavigationController)
Atm i open my popover here:
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)
Ok, now i am on my popoverAddItems ViewController, but how can i get here, in this UINavigationController add a Photolibrary?
So i can use it when i close my existing 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)
Any Ideas? Any help would be greatly appreciated
To show an UIImagePickerController inside your popover (which - in your case - is an UINavigationController inside an UIPopoverController) use the following code in your 'showImagePicker:' routine:
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];
When you call this from inside your UINavigationControllers viewController hierarchy, everything's fine. If you call it from somewhere else, make sure, that your use the UINavigationController item which is used in the UIPopoverController to present the UIImagePickerController.