简体   繁体   English

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

[英]How do I find the frame of a UIView in the context of a UIScrollView?

I'm trying to place a UIPopoverController to display when a UIButton is tapped. 我正在尝试放置一个UIPopoverController来显示何时点击UIButton However, the UIButton is placed within a UIScrollView and so its frame is offset by the scroll amount. 但是, UIButton放在UIScrollView ,因此其框架由滚动量偏移。

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 ? 或者我只需要在UIButton框架和UIScrollViewcontentOffset之间进行减法操作?

Thanks! 谢谢!

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. 如果您正在使用- (void)presentPopoverFromRect:(CGRect)rect inView:(UIView *)view permittedArrowDirections:(UIPopoverArrowDirection)arrowDirections animated:(BOOL)animated则您已经在指定要从中呈现的视图。 Just present the popover from 0,0 0,0 in your UIButton . 只需在你的UIButton 0,0 0,0的UIButton

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM