mapping a uiscrollview contentview position to its frame?
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];
精彩评论