如何在 UIScrollView 的上下文中找到 UIView 的框架?
我试图放置一个 UIPopoverController
来在点击 UIButton
时显示。但是,UIButton
放置在 UIScrollView
内,因此其框架会偏移滚动量。
有没有一种简单的方法可以找到出现在屏幕上下文中的视图框架?或者我只需要在 UIButton
框架和 UIScrollView
的 contentOffset
之间进行减法?
谢谢!
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您使用
- (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 yourUIButton
.