Reputation: 12596
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!
Upvotes: 0
Views: 130
Reputation: 5180
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.
Upvotes: 1