UIPopoverController 锚点位置

发布于 2024-10-29 03:05:29 字数 374 浏览 7 评论 0原文

我有一个 UIPopOverController,其内容控制器是 UINavigationController。 我正在根据推入/弹出的控制器的内容大小调整弹出窗口的大小。最初,我使用方法 presentPopoverFromRect:inView:permissedArrowDirections:animated: 来呈现弹出窗口。锚点位置指向我作为参数传递的矩形的中心。如果我将一个控制器(其内容大小很小)推入 navigationController ,弹出窗口会从底部缩小并移动到我之前提到的矩形上方。

我尝试每次都呈现弹出窗口(对于推送/弹出),锚点位置保持@同一点,但动画受到影响,看起来不太好。

无论弹出窗口大小变化如何变化,需要做什么才能使锚点位置保持不变?

I have a UIPopOverController for which the content controller is a UINavigationController.
I'm resizing the popover size according to the content size of the controller pushed/popped into it. Initally i'm presenting the popover by using the method presentPopoverFromRect:inView:permittedArrowDirections:animated:. The anchor position is pointing at the center of the rect which i passed as an argument. If i push a controller(whose content size is small) into the navigationController , the popover shrinks from the bottom and moves above the rect which i mentioned earlier.

I tried to present the popover everytime(for push/pop) , anchor position remains @ same point But the animation gets affected , doesnt looks good.

what needs to be done to make the anchor position remains same irrespective of the change in popover size variation ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

南风几经秋 2024-11-05 03:05:29

我遇到了同样的问题,似乎再次调用 presentPopoverFromRect 方法将使锚点保持在相同的位置,

例如

[self.myPopOver presentPopoverFromRect:rectOrigin inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:NO];

希望它也适用于你的情况

I've encountered the same issue and it seems that calling the presentPopoverFromRect method again will keep the anchor at the same position

e.g.

[self.myPopOver presentPopoverFromRect:rectOrigin inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:NO];

Hope it works in your case as well

つ可否回来 2024-11-05 03:05:29

呈现 UIPopoverController 后更改框架:

 [popupController presentPopoverFromRect:btn.frame inView:self.view permittedArrowDirections:0 animated:YES];

CGRect popupFrame = popupController.contentViewController.view.superview.superview.superview.frame;
popupFrame.origin.y = btn.frame.origin.y + btn.frame.size.height+75;

popupController.contentViewController.view.superview.superview.superview.frame = popupFrame;

Change frame after presenting UIPopoverController:

 [popupController presentPopoverFromRect:btn.frame inView:self.view permittedArrowDirections:0 animated:YES];

CGRect popupFrame = popupController.contentViewController.view.superview.superview.superview.frame;
popupFrame.origin.y = btn.frame.origin.y + btn.frame.size.height+75;

popupController.contentViewController.view.superview.superview.superview.frame = popupFrame;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文