Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

centering a uipopover in iPad

I would like to create a new keyboard for the iPad.

I have designed a view that has the keys and all the underlying work to fill in a textbox as the user presses the keys, and passes the value back to the calling routine when the user presses the return button.

This all works ok.

Now - I want to create this view as a popover.

I have the basic operations complete (pops up and is dismissed)

But now I need some fine tuning help.

Here are my questions...

1) How do I create a popover window centered on the screen without a UIPopoverArrowDirectionAny selection?

2) Ensure the popover window is the size that I created it with in the XIB file (currently, it resizes and removes some of the rightmost size of the window)

Thanks
tony

like image 821
pithhelmet Avatar asked Nov 19 '10 18:11

pithhelmet


1 Answers

To present it with no arrows pass 0 for "permittedArrowDirections":

[popOverController presentPopoverFromRect:rect inView:view permittedArrowDirections:0 animated:YES];

To center it, pass a 1x1 rect located at the center of your view:

CGRect rect = CGRectMake(viewWidth/2, viewHeight/2, 1, 1);
[popOverController presentPopoverFromRect:rect inView:view permittedArrowDirections:0 animated:YES];

Then you have a centered and arrow-free popover.

The bit about removing the arrow could break at any time. They didn't provide a UIPopoverArrowDirectionNone option for a reason, they may choose to throw an exception in the future when 0 is passed, or default to something. Use it at your own risk.

like image 153
George Avatar answered Oct 15 '22 03:10

George