tags:

views:

46

answers:

2

I have an object that is drawn near the first third of the screen. Imagine that there are 300 pixels between the top of the object (an image, for example) and the top of the screen.

When I show a popover, lets say, with 200x200 pixels and specify arrow direction as any, the popover may appear over the object, that is, between the object and the top of the screen.

If the popover for some reason, loads another view and is resized to more than the available space between the object and the top of the screen, it will not be able to fit there. iOS solves that, forbidden the popover to resize to more than possible. The result is that the content gets truncated and probably the popover will move a little bit and the arrow will point to nowhere.

Is there any way to make a popover that has increased to recalculate the best arrow direction?

thanks.

A: 

What happens if you dismiss the popover and then re-present it after the content size has changed?

Robot K
I like how it is done now... the popover animates from one size to the other and back...
Digital Robot
I think you're going to have to choose one or the other. Cool animation with truncated content, or lousy animation with full content. As best as I can tell, you can't get both.
Robot K
+1  A: 

You can calculate the size of your needed future content (contentView) and compare it to your threshold and force the arrow direction. you may need to experiment with your threshold as the size of a content view isnt the entire height of the popover.

int popoverArrowDirection 15;//any
int threshold = 300;        
        if(viewThatWillbeInserted.frame.size.height>threshold)popoverArrowDirection = 1;//up


[myPopoverController presentPopoverFromBarButtonItem:myBarButton permittedArrowDirections:popoverArrowDirection animated:YES];

If you cant know this height before then you don't have many options.

The limitations of popovers drove me to mock-up a popover as Custom ViewController (like the page popover you see when you slide through the pages in a ibook; thats not an actual popover component). This would mean that if you had a down arrow, and pushed on a new bigger view you could even animate the view spinning around the origin of arrow tip or any other stupid animations..

I have only done this in enterprise apps, and am unsure weather this is app-store safe!

Luke Mcneice
I was suspecting that I would have to do something like that, but I was hoping there was a way to do it automatically... Popovers are good if your buttons are steady. If they move, then they suck. I will fill a bug report. Thanks.
Digital Robot