Kyle
Kyle

Reputation: 17677

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?

Upvotes: 2

Views: 652

Answers (1)

Raphaël Mor
Raphaël Mor

Reputation: 356

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];

Upvotes: 1

Related Questions