在 iPad 中将 uipopover 居中
我想为 iPad 创建一个新键盘。
我设计了一个视图,其中包含按键和所有底层工作,以在用户按下按键时填充文本框,并在用户按下返回按钮时将值传递回调用例程。
这一切都正常。
现在 - 我想创建这个视图作为弹出窗口。
我已经完成了基本操作(弹出并被取消),
但现在我需要一些微调帮助。
这是我的问题...
1)如何在没有 UIPopoverArrowDirectionAny 选择的情况下创建以屏幕为中心的弹出窗口?
2)确保弹出窗口的大小是我在 XIB 文件中创建的大小(目前,它调整大小并删除窗口最右边的一些大小)
谢谢
托尼
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
要在没有箭头的情况下显示它,请为“permissedArrowDirections”传递 0:
要使其居中,请传递位于视图中心的 1x1 矩形:
然后您将获得一个居中且无箭头的弹出框。
移除箭头的部分随时可能断裂。他们没有提供 UIPopoverArrowDirectionNone 选项是有原因的,他们可能会选择在将来传递 0 时抛出异常,或者默认为某个值。使用它的风险由您自行承担。
To present it with no arrows pass 0 for "permittedArrowDirections":
To center it, pass a 1x1 rect located at the center of your view:
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.
如果您使用的是 UIPopoverController,它将有一个箭头。这是您的选择。
正如您所看到的,没有 UIPopoverArrowDirectionNone
至于 XIB 大小,在您的实现文件的 ViewDidLoad 方法中,您可以设置以下内容。
您可以按照自己喜欢的方式设置弹出窗口的大小。
If you are using a UIPopoverController, it will have an arrow. Here are your choices.
As you can see there is no UIPopoverArrowDirectionNone
As for the XIB size, in your ViewDidLoad Method of the implementation file, you can set the following.
You can set the size any way you like for the popover.
我刚刚解决了这个问题,但想在故事板中做尽可能多的事情,这稍微改变了方法:
1)在故事板中选择弹出窗口,然后取消勾选方向向上/向下/向左/向右以摆脱的箭头。
要将其集中在屏幕覆盖上,请为segue做好准备并执行以下操作:
在我的情况下,我还发现弹出框segue的角半径与我的设计不匹配,因此我将背景颜色更改为清除以进行排序,即将其添加到上面的块:
2)在segue的目标控制器中找到属性“Popover”并勾选“使用显式大小”并输入您希望它以弹出模式显示的大小。
I've just been working this one out but wanted to do as much in the storyboard as possible which changes the approach a bit:
1) Select the popover in the storyboard and un-tick Directions Up/Down/Left/Right to get rid of the arrows.
To center it on screen override prepare for segue and do something like this:
In my case I also found that the popover segue's corner radius didn't match my design so I change the background color to clear to sort that out i.e. add this to the above block:
2) In the destination controller for the segue find the attribute 'Popover' and tick 'Use Explicit Size' and put the size of you want it to appear in popover mode.