简体   繁体   English

将触摸从UIView传递到其下方的UIScrollView

[英]Pass touches from a UIView to UIScrollView beneath it

I have a UIScrollView stretching over the entire screen, which the user is able to scroll vertically only. 我有一个UIScrollView延伸到整个屏幕,用户只能垂直滚动。 Right 'above' it is a UIView with a few buttons, which covers the bottom 120 px only. 在“上方”是一个带有几个按钮的UIView ,仅覆盖底部的120像素。 The user may tap the buttons to invoke their selectors. 用户可以点击按钮以调用他们的选择器。 But I wish to be able to pass the panning movement to the scrollView, so that the user may scroll the scrollView if they pan with a velocity greater than a certain threshold, if the panning begins over the UIView . 但是我希望能够将平移运动传递给scrollView,这样,如果平移开始于UIView ,则用户以大于某个阈值的速度平移时可以滚动scrollView。

How would I go about it? 我将如何处理?

Thanks 谢谢

You can do 2 things. 您可以做两件事。

  1. Add a UITouchesMoved function to your uiView, calculate finger movement and move your scrollView accordingly by scrolling it to a CGPoint . 在您的uiView中添加一个UITouchesMoved函数,计算手指的移动,并通过滚动到CGPoint来相应地移动滚动视图。

  2. You can use UIPanGestureRecognizer. 您可以使用UIPanGestureRecognizer。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM