I present a popover programmatically from a button on toolbar. I successfully implemented it on Xcode 8.1.
_myMapViewController.modalPresentationStyle = UIModalPresentationPopover;
switch ([[UIApplication sharedApplication] statusBarOrientation]) {
case UIInterfaceOrientationPortrait:
case UIInterfaceOrientationPortraitUpsideDown:
// Resize Popover
_myMapViewController.preferredContentSize = self.popoverSizeForPortrait;
break;
case UIInterfaceOrientationLandscapeLeft:
case UIInterfaceOrientationLandscapeRight:
// Resize Popover
_myMapViewController.preferredContentSize = self.popoverSizeForLandscape;
break;
default:
//do nothing
break;
}
UIPopoverPresentationController *popoverPresentation = _myMapViewController.popoverPresentationController;
[popoverPresentation setBarButtonItem:_mapButton];
[popoverPresentation setPermittedArrowDirections:UIPopoverArrowDirectionDown];
[popoverPresentation setDelegate:self];
[self presentViewController:_myMapViewController animated:YES completion:nil];
Below is a successful outcome on iPhone 7. You see a popover of a map anchored to compass button on the bottom left.
However, when I run the same code with iPhone 6 Plus and 7 Plus simulators, the popover in landscape mode is shown from unknown (and unintended) anchor) like this:
Showing the popover in portrait mode has no issues. Any idea for resolution would be appreciated.