0

I have a UIScrollView that scrolls horizontally. I have about 10 views lined up horizontally in that scrollview. I want to find the view that contains the center point of the scrollview's frame (not contentView.frame) as it scrolls. I am thinking to use the - (void)scrollViewDidScroll:(UIScrollView *)scrollView UIScrollView delegate method, but I am not sure how to find this.

Thanks!

SirRupertIII
  • 12,324
  • 20
  • 72
  • 121

1 Answers1

1

You can get the start-point of a frame of a view (myChildView) in the reference of another view (scrollView) using the following code:

CGPoint origin = [myChildView convertPoint:CGPointMake(myChildView.bounds.origin.x, myChildView.bounds.origin.y) toView:[self scrollView]];

Use the scrollViewDidScroll: delegate method to pick your views and perform the calculations there.

ArtSabintsev
  • 5,170
  • 10
  • 41
  • 71