iPad - redrawing the arrow direction of a visible UIPopOverController
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 h开发者_如何学Pythonas increased to recalculate the best arrow direction?
thanks.
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!
What happens if you dismiss the popover and then re-present it after the content size has changed?
精彩评论