开发者

mapping a uiscrollview contentview position to its frame?

开发者 https://www.devze.com 2023-01-07 05:28 出处:网络
I have a UIScrollView where the content size is larger than the frame.开发者_运维问答 I am displaying a UIPopoverController and want to use the frame of a UIImageView for the call to set where the pop

I have a UIScrollView where the content size is larger than the frame.开发者_运维问答 I am displaying a UIPopoverController and want to use the frame of a UIImageView for the call to set where the popover will be placed:

[popoverController presentPopoverFromRect: imageView.frame inView: self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

This works fine If I have not scrolled at all. But as soon as I start scrolling, the frame of the imageview is outside of the frame of the scrollview so the popover always displays on the incorrect y axis.

Is there a way to map this position to display in the proper location?


Have you tried using - (CGRect)convertRect:(CGRect)rect toView:(UIView *)view

Something like :

CGRect convertedFrame = [scrollView convertRect:imageView.frame toView:self.view];
[popoverController presentPopoverFromRect:convertedFrame inView: self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
0

精彩评论

暂无评论...
验证码 换一张
取 消