Controlling the size of a PopOver container or screen

When I show a popover screen, I get some random size that doesn’t seem adjustable.

When I show a popover container, I get the container size but the controls in the container get shifted based on the direction of the arrow of the popover (I’m clicking on objects in a canvas and popover points to the location of the object on the canvas).

The documentation for the MobileContainer.ShowPopOver indicates that you might have to set constraints in code:

https://documentation.xojo.com/api/user_interface/mobile/mobilecontainer.html#mobilecontainer-showpopover

But there’s no examples of how to do this. It seems like there’s an implicit screen that holds the container. Is this “Self”?

Anyone have any experience with this?

I see the same.
MobileScreen.ShowPopover should not be used in any project that can run on iPad.

If you have iOSDesignExtensions, you can change the size like this (only applies to iPad), but it will not display the arrow.

Var popover As new ScreenPopover
popover.ShowModal(parent, MobileScreen.ModalPresentationStyles.FormSheet)

popover.SetPreferredContentSizeXC(new Size(540, 620))

When using MobileContainer.ShowPopover, you can define constraints in the MobileContainer opening event (only applies to iPad)

Var width As New iOSLayoutConstraint(self, _
iOSLayoutConstraint.AttributeTypes.Width, _
iOSLayoutConstraint.RelationTypes.Equal, _
nil, iOSLayoutConstraint.AttributeTypes.None, _
1.0, 500)
self.AddConstraint(width) //Self is the mobilecontainer

Var Height As New iOSLayoutConstraint(self, _
iOSLayoutConstraint.AttributeTypes.Height, _
iOSLayoutConstraint.RelationTypes.Equal, _
nil, iOSLayoutConstraint.AttributeTypes.None, _
1.0, 500)
self.AddConstraint(Height)

1 Like

You are correct, there is an implicit MobileScreen that holds the container. That screen can not be accessed by code (except with quite complex Declares).

1 Like

And I just noticed a few issues:

  • On iOS 11 and 12, popovers can’t be closed as iOS didn’t have that slide-down mechanism
  • On iPhone in landscape mode, popovers can’t be closed with the slide-down mechanism
  • There is no way to close a popover by code

TL;DR

Don’t use ShowPopover on iOS.

1 Like

Thanks, Jeremie. Excellent suggestions as usual. I’m going to play with the constraints and see if that does anything to solve the shifting controls issue.

The constraints don’t do anything useful. So this note in the documentation remains mysterious:

You may have to add constraints via code before calling this method so that the container will resize to fill the popover.