禁用 UIScrollView 中子视图的滚动
我在滚动视图的顶部有一个视频播放器视图,并且添加了垂直滑动来调整音量和亮度功能。
问题是当我在播放器视图中滑动来调整音量时,滚动视图也会滚动,我该如何防止它呢?
I have a video player view on the top of the scroll view, and I added swipe vertically to adjust volume and brightness feature.
The problem is when I swipe in the player view to adjust the volume, the scroll view scrolls as well, how can I prevent it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这可能适合您的用例。
我假设您在视频视图上添加了平移手势,因此在操作处理程序中,您可以在手势状态为
.began
或时禁用滚动视图滚动>.changed
并为任何状态重新启用它,例如end
或cancelled
以下是我的做法:
以下是发生的情况的示例这段代码:
This could probably work for your use case.
I am assuming you added a
pan gesture
on your video view and so in your action handler, you could disable the scrollview from scrolling when the gesture's state is.began
or.changed
and re-enable it for any any state such asended
orcancelled
Here is how I did that:
Here is an example of what happens with this code: