UIScrollViews all scroll in the same time

无人久伴 提交于 2019-12-06 07:53:10

Keep an array of all of your UIScrollView objects. Make sure all of their delegates point to the same object (or if that's not possible, there is some sort of handler that gets called on scrollViewDidScroll). Then use setContentOffset to adjust the offsets. You had the right idea, but you just want to make sure all scroll views except the current view (which is determined by the delegate method argument) is scrolling.

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
  for (UIScrollView *view in self.scrollViews) {
    if (scrollView != view) {
      [view setContentOffset:scrollView.contentOffset];
    }
  }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!