开发者

How can I programmatically change the position of a UIScrollView based on another views change?

I have a scrollView that I'd like to programmatically move based on the delta, or change of another scrollView. So if my first scrollView moves down 10px, I need to get that number, and adjust the second scrollView down 10px, and allow them to be in different positions.

The only other way I've gotten it to work (thanks to som开发者_开发知识库eone else's post on here) is with this code:

[scrollView setContentOffset:offset animated:NO];

But that just makes them have the same XY coordinates, which isn't what I'm looking for.

Thanks for your help!


Just use the delegate method

- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView

To determine the value of each content offset when scrolling starts. Then each time scrolling is updated you can tell how much it has changed by, and adjust the other scroll view. It's just math.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜