Reputation: 2302
I have a popover where the SourceRect is the setting button (the button with a gear icon). The popover position is correct for all device orientation except for LandscapeLeft.
I set the anchor from XCode Interface builder and set the source rect programmatically:
var poc = segue.DestinationViewController as PVPencilOptionsController;
poc.ViewModel = this.ViewModel.ColorPicker;
var ppc = (UIPopoverPresentationController)poc.PresentationController;
ppc.SourceRect = this.PVEditIssuePhotoPencilOptionsButton.Frame;
Below are the result of popover position:
Portrait/upside down (correct):
Landscape Right (correct):
Landscape Left (wrong)
As you can see, if the device orientation is Landscape Left, there is a gap between the popover arrow and the setting button.
How to find out where this gap come from?
Upvotes: 1
Views: 958
Reputation: 4346
I've had simlar issues and mine was all due to the fact that I was calculating my sizing and my positioning in the wrong place, sometimes using the wrong values as well. There's two things I would suggest to find your problem:
1. Do all position/sizing calculations in LayoutSubviews: Override the LayoutSubviews in your controller and calculate your positioning information in there. After the base call.
2. Log out dimensions of Frame as well as Bounds: This way you can see what you have and where you want it to be. Do this before and after layout subviews to see the difference.
Upvotes: 1