如何在 UIScrollView 的上下文中找到 UIView 的框架?

发布于 2024-09-29 22:47:24 字数 294 浏览 2 评论 0原文

我试图放置一个 UIPopoverController 来在点击 UIButton 时显示。但是,UIButton 放置在 UIScrollView 内,因此其框架会偏移滚动量。

有没有一种简单的方法可以找到出现在屏幕上下文中的视图框架?或者我只需要在 UIButton 框架和 UIScrollViewcontentOffset 之间进行减法?

谢谢!

I'm trying to place a UIPopoverController to display when a UIButton is tapped. However, the UIButton is placed within a UIScrollView and so its frame is offset by the scroll amount.

Is there an easy way of finding out a view's frame as it appears in the context of the screen? Or do I just need to do a subtraction between the UIButton frame and the contentOffset of the UIScrollView?

Thanks!

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

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

发布评论

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

评论(1

一瞬间的火花 2024-10-06 22:47:24

如果您使用 - (void)presentPopoverFromRect:(CGRect)rect inView:(UIView *)view allowedArrowDirections:(UIPopoverArrowDirection)arrowDirectionsAnimated:(BOOL)animated 那么您已经指定了您所在的视图想要呈现来自。只需在 UIButton 中显示从 0,0 0,0 开始的弹出框即可。

If you are using - (void)presentPopoverFromRect:(CGRect)rect inView:(UIView *)view permittedArrowDirections:(UIPopoverArrowDirection)arrowDirections animated:(BOOL)animated then you are already specifying the view that you are wanting to present from. Just present the popover from 0,0 0,0 in your UIButton.

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