从UIScrollView转发垂直滚动到兄弟UITableView [英] Forward vertical scrolls from UIScrollView to a sibling UITableView

查看:149
本文介绍了从UIScrollView转发垂直滚动到兄弟UITableView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个具有此层次结构的视图控制器:

I have a view controller with this hierarchy:

查看控制器:


  • UIScrollView(水平滚动)

  • UITableView(垂直滚动)

我想转发我的垂直卷轴 UIScrollView 到兄弟 UITableView ,这样当用户向上滚动 UIScrollView UITableView 将向上滚动。最好的方法是什么?

I want to forward the vertical scrolls from my UIScrollView to the sibling UITableView, so that when the user scrolls up on the UIScrollView, the UITableView will scroll up instead. What would be the best way to do it?

我试过这些:


  • 检测 scrollViewDidScroll 中的垂直滚动,因为滚动视图的contentOffset没有改变,所以不会调用它。

  • UIScrollView 进行子类化并覆盖 touchesMoved ,我无法将触摸转发到表视图,因为我没有在这个类中引用它。

  • Detecting the vertical scroll in scrollViewDidScroll, it doesn't get called because the contentOffset of the scroll view does not change.
  • Subclassing the UIScrollView and overriding touchesMoved, I can't forward the touches to the table view because I don't have a reference to it in this class.

推荐答案

这将使你的滚动同时与 UITableView UIScrollView 并应用 @Stephen Johnson 的阻止

This will make your scroll simultaneously with UITableView and UIScrollView and apply @Stephen Johnson's block

 - (BOOL)gestureRecognizer:(UIPanGestureRecognizer *)gestureRecognizer
 shouldRecognizeSimultaneouslyWithGestureRecognizer:(UISwipeGestureRecognizer *)otherGestureRecognizer
 {
     return YES;
 }

这篇关于从UIScrollView转发垂直滚动到兄弟UITableView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆