如何使用presentPopoverFromRect制作弹出框和箭头?
我不明白如何定义 (CGRect)rect
来控制弹出框的位置和箭头的位置。
例如,我有一个 1004 x 768 视图,如何将弹出窗口放在屏幕右下角,并将箭头指向 700 (x) 1000 (y)?
I don't understand how to define the (CGRect)rect
in order to control the position of popover, and the position of the arrow.
For example, I have a 1004 x 768 view, how can I put the popover at lower right of the screen, and point the arrow at 700 (x) 1000 (y)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Nickthedude 关于presentpopoverfromrect 的说法是正确的,但是presentpopoverfromrect 函数有一个重要的时刻:如果您没有设置popover 的contentSizeForViewInPopover 属性,它将使用默认值 - 320*1100 点。如果您的弹出框的矩形不适合屏幕坐标(您的坐标是从当前弹出框的矩形中获取的),系统会将您的弹出框放置到它认为更理想的矩形中。
Nickthedude is right about presentpopoverfromrect, but there is one essential moment with presentpopoverfromrect function: if you don't set popover's contentSizeForViewInPopover property it use defult values - 320*1100 points. And if you popover's rect doesn't fit into screen coordinates (with your coordinates got from the presentpopoverfromrect rect), system places your popover to rectangle which it considered as more optimal.
Cgrectmake(700,1000,10,10) 和 uipopoverarrowdirectionleft 抱歉,我在 iPad 上,所以我无法编写确切的代码,但将它们作为您的 presentpopoverfromrect 方法的参数传递。唯一的问题是我认为你太偏右了,无法在那里放置弹出窗口,除非我不理解你的问题。
Cgrectmake(700,1000,10,10) and uipopoverarrowdirectionleft sorry I'm on my iPad so I can't write the exact code but pass those in as the arguments for your presentpopoverfromrect method. The only thing is i think you're too far to the right to put a popover there unless I'm not understanding your question.