如何根据另一个视图的更改以编程方式更改 UIScrollView 的位置?
我有一个滚动视图,我想根据增量以编程方式移动该滚动视图,或更改另一个滚动视图。因此,如果我的第一个scrollView向下移动10px,我需要获取该数字,并将第二个scrollView向下调整10px,并允许它们位于不同的位置。
我让它工作的唯一其他方法(感谢这里其他人的帖子)是使用这段代码:
[scrollView setContentOffset:offset animated:NO];
但这只会使它们具有相同的 XY 坐标,这不是我想要的。
感谢您的帮助!
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 someone 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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需使用委托方法
来确定滚动开始时每个内容偏移的值。然后,每次更新滚动时,您都可以知道它改变了多少,并调整其他滚动视图。这只是数学。
Just use the delegate method
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.