没有任何箭头的 UIPopover
是否可以呈现一个没有任何指向某处的箭头的弹出窗口?
Is it possible to present a popover without any sort of arrows pointing somewhere?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
是否可以呈现一个没有任何指向某处的箭头的弹出窗口?
Is it possible to present a popover without any sort of arrows pointing somewhere?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(17)
就我而言,对于快速开发人员来说
In my case for swift developers
不,没有
UIPopoverArrowDirectionNone
选项,并且UIPopoverArrowDirectionUnknown
会抛出异常,我认为如果您尝试使用它来呈现。您可以调用
presentModalViewController:animated:
并将要呈现的控制器设置为具有UIModalPresentationFormSheet
或UIModalPresentationPageSheet
模式呈现样式,而不是弹出窗口控制器。代码>.这些是比弹出窗口更传统的弹出屏幕。Nope, there is no
UIPopoverArrowDirectionNone
option, andUIPopoverArrowDirectionUnknown
throws an exception i think if you try to use that to present.Instead of a popover controller, you can call
presentModalViewController:animated:
and set the controller you are presenting to have a modal presentation style ofUIModalPresentationFormSheet
or perhapsUIModalPresentationPageSheet
. Those are more traditional popup screens than popovers are.这对我来说效果很好。
享受编码。
This works fine for me.
Enjoy Coding.
如果您不想显示箭头,请不要使用 Popovers。将视图控制器呈现为 Modal 并使用 UIModalPresentationFormSheet 代替。
例子:
Do not use Popovers if you don't want to show arrows. Present your view controller as a Modal and use a UIModalPresentationFormSheet instead.
Example:
试试这个
Try this one
我使用弹出窗口根据触摸坐标显示菜单。
在这种情况下,弹出窗口使用 self.view 的最大高度
但是当我使用 0 方向时。弹出框矩形不会将其高度设置为最大值,只能通过适当的属性进行设置。
希望这会有所帮助:有关 UIPopOverController 大小的帮助
I use popover to show menu depending on touch coordinate.
In this case popover uses maximum height of self.view
But when I use 0-direction. Popover rectangle doesn't set it height to maximum and can only be set by appropriate property.
Hope this will help: Help with UIPopOverController size
要使弹出方向无并使其出现在视图控制器的中心:
To make a pop over direction none and make it to appear in center of the view controller :
SWIFT 中的一个简单解决方案:
A simple solution in SWIFT:
是的,可以这样做:
零代表没有方向。
Yes it is possible just do:
The zero represent no direction.
对于 iPhone 和 swift 2.0 尝试这个代码
来启动弹出窗口
并将其添加到您的 ViewController
For iPhone and swift 2.0 try this one
Code to initiate popover
And add this to your ViewController
Swift4:
Swift4:
将
permissedArrowDirections
设置为 0。代码 -
零表示“NoDirection”。
Set the
permittedArrowDirections
to 0.Code -
Zero tells "NoDirection".
Swift3,这段代码对我有用
Swift3, this code work for me
对于
Swift 2.0
和iOS9
解决方案是:For
Swift 2.0
andiOS9
the solution is:在 swift 3 中,您可以为此构建一个
UIPopoverArrowDirection
扩展:并且您可以执行以下操作:
In swift 3, you can build a
UIPopoverArrowDirection
extension for this:and the you can do:
在 Swift 中,您可以简单地执行以下操作:
因为在另一个配置中您可以使用:
In Swift, you can simply do:
Since in another configuration you could have used:
试试这个,它对我有用。
Try this , it works for me.