Search code examples
iosipadcore-animationuipopovercontrollerpopover

Core animation depending on a popover - iPad


I need to do an animation where a UIView shifts to the left when a popover shows. It works ok but so far I have hardcoded the distance it shifts. Obviously the problem is that if the popover is visible and the device rotates, the popover ends up overlaping a bit with the view.

So I would rather need a way to know the popover's frame so that I woulsn't have to hardcode the distance.

Is there any way to achieve that?

Thanks in advance!


Solution

  • I haven't tried this, but you should be able to query the following, in order:

    The popoverContentSize of the popover. If it's non-zero, that's your size.

    The contentSizeForViewInPopover property of the view controller that's being displayed in the popover. If that's non-zero, that's your size

    The bounds.size of the displayed view controller's content view.

    Or do you need the popover's location as well as it's size? That would be harder, since it depends on the rectangle you provide as the source of the popover, the arrow directions you specify, and screen layout.

    You're going to have to be more specific in order to get a specific solution.