iOS 8 - UIPopoverPresentationController移动弹出窗口 [英] iOS 8 - UIPopoverPresentationController moving popover

查看:514
本文介绍了iOS 8 - UIPopoverPresentationController移动弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种有效的方法来使用新的uipopoverpresentationcontroller重新定位一个popover。我已成功地呈现了弹出窗口,现在我想移动它而不会解散并再次呈现。我在使用该函数时遇到问题:

I am looking for an effective way to re-position a popover using the new uipopoverpresentationcontroller. I have succesfully presented the popover, and now I want to move it without dismissing and presenting again. I am having trouble using the function:

(void)popoverPresentationController:(UIPopoverPresentationController *)popoverPresentationController
      willRepositionPopoverToRect:(inout CGRect *)rect
                           inView:(inout UIView **)view

我知道它早在游戏中,但任何人都有一个如何有效地做到这一点的例子,如果你与我分享,我将不胜感激。提前致谢。

I know it's early in the game, but it anyone has an example of how to do this efficiently I would be grateful if you shared it with me. Thanks in advance.

推荐答案

不幸的是,这个hacky解决方法是我找到的唯一解决方案:

Unfortunately this hacky workaround is the only solution I've found:

[vc.popoverPresentationController setSourceRect:newSourceRect];
[vc setPreferredContentSize:CGRectInset(vc.view.frame, -0.01, 0.0).size];

这会暂时更改所呈现视图的内容大小,从而导致弹出框和箭头重新定位。临时改变大小不可见。

This temporarily changes the content size of the presented view, causing the popover and arrow to be repositioned. The temporary change in size is not visible.

这似乎是Apple需要解决的问题 - 更改 sourceView sourceRect UIPopoverPresentationController 的属性在它已经呈现弹出窗口时没有任何作用(没有此解决方法)。

It seems this is a problem Apple need to fix - changing the sourceView or sourceRect properties of UIPopoverPresentationController does nothing when it's already presenting a popover (without this workaround).

希望这也适合你!

这篇关于iOS 8 - UIPopoverPresentationController移动弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆