简体   繁体   中英

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. 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!

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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