I have discovered a situation that causes dismissViewController:animated:completion
to not dismiss the view controller that has been presented. While it does dismiss on iPad running iOS 8, it doesn't dismiss on iPad running iOS 7.1. I've tried self
, self.presentingViewController
, and self.presentedViewController
- all do nothing. I've tried it with Xcode 6.0 and 6.1 beta. While I do believe this is a bug, what can be done to work around it and force dismiss that view controller, ensuring it will work for iPad running iOS 7 and 8 (presented as a popover), and iPhone running iOS 7 and 8 (presented full screen)?
I have created a very simple project you may use to try this: Xcode project zip.
Project setup:
To encounter the unexpected behavior:
The problem is in the way you try to handle the popover. To close the popover you should use the dismissPopoverAnimated
method instead of dismissViewControllerAnimated
.
I think you will have to make more work to complete your task for targeting both iOS versions. The root view controller should have some property to store the created popover with PoppedUpTVC as popover content and the PoppedUpTVC has to ask the root view controller to perform dismissPopoverAnimated
method on the stored popover to close it.
To get a reference to the popover, try this in prepareForSegue
:
if ([segue isKindOfClass:[UIStoryboardPopoverSegue class]]) {
UIStoryboardPopoverSegue *popoverSegue = (UIStoryboardPopoverSegue *)segue;
yourDestViewController.propertyToStorePopover = popoverSegue.popoverController;
}