我有两个嵌套的 UIScrollView,都在垂直方向滚动.在允许内部滚动视图滚动之前,我需要先将外部滚动视图滚动到它的最大范围.在外部滚动视图达到其最大范围之前,内部滚动视图不应滚动.这是一个插图:
I have two nested UIScrollViews, both scrolling in the vertical direction. I need the outer scrollview to scroll to it's max range first before allowing the inner scrollview to scroll. The inner scrollview should not be scrollable until the outer scrollview has reached it's max range. Here's an illustration:
在左图中,Scrollview B 内的垂直拖动应移动 Scrollview A 并且 Scrollview B 不应滚动(但它仍然需要能够接收触摸/点击).一旦 Scrollview A 达到它的最大范围(当 Scrollview B 到达屏幕顶部时),则 Scrollview B 应该滚动.这需要以一个连续的动作进行.
In the left diagram, a vertical drag inside of Scrollview B should move Scrollview A and Scrollview B should not be scrollable (but it still needs to be able to receive touches/taps). Once Scrollview A reaches it's max range (when Scrollview B gets to the top of the screen), then Scrollview B should scroll. This needs to work in one continuous motion.
我试图从 ScrollView A 的 scrollViewDidScroll: 委托切换 ScrollView B 的 scrollEnabled方法,但这似乎不是一个可行的解决方案,因为它不能在一个连续运动中工作(例如:用户需要在 Scrollview B 到达屏幕顶部后再次释放并触摸).
I've attempted to toggle ScrollView B's scrollEnabled from ScrollView A's scrollViewDidScroll: delegate method, but this doesn't appear to be a viable solution because it doesn't work in one continuous motion (eg: The user needs to release and touch again after Scrollview B reaches the top of the screen).
在一个连续的动作中实现这一点的最佳方法是什么?
What's the best way to implement this such that is works in one continuous motion?
在我的例子中,我解决了为外部 ScrollView 子类化 UIScrollView.
In my case I solved subclassing UIScrollView for the outer ScrollView.
class MYOuterScrollView: UIScrollView, UIGestureRecognizerDelegate
{
override func gestureRecognizerShouldBegin(gestureRecognizer: UIGestureRecognizer) -> Bool
{
return true
}
func gestureRecognizer(gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWithGestureRecognizer otherGestureRecognizer: UIGestureRecognizer) -> Bool
{
return true
}
}
这篇关于处理嵌套 UIScrollViews 在同一方向滚动的触摸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
UIScrollView 底部的 UIButtons 不起作用UIButtons at the bottom of UIScrollView not working(UIScrollView 底部的 UIButtons 不起作用)
scrollViewWillEndDragging:withVelocity:targetContentOffset: 不scrollViewWillEndDragging:withVelocity:targetContentOffset: not working on the edges of a UISCrollView(scrollViewWillEndDragging:withVelocity:targetCon
向下滚动时 ImageView 缩放ImageView Scaling when scrolling down(向下滚动时 ImageView 缩放)
UIScrollView 上的边界自动更改,带有内容插图Bounds automatically changes on UIScrollView with content insets(UIScrollView 上的边界自动更改,带有内容插图)
用于 UIScrollView 的 iOS5 UITapRecognizer 干扰按钮.怎么iOS5 UITapRecognizer for UIScrollView interfering with buttons. How to fix?(用于 UIScrollView 的 iOS5 UITapRecognizer 干扰按钮.怎么修?)
使用(自定义、交互式)视图控制器呈现和解除处理Handling scroll views with (custom, interactive) view controller presentation and dismissal(使用(自定义、交互式)视图控制器呈现和解除处