UISlider 和 UIScrollView [英] UISlider and UIScrollView

查看:18
本文介绍了UISlider 和 UIScrollView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 UISlider 作为视图的一部分,该视图加载到启用分页的 UIScrollView 中.我注意到了一个意外的行为.如果用户试图快速使用滑块(即按下并移动),它会激活"滚动视图,从而导致页面切换.但是,如果您按住一秒钟滑块激活",然后您可以调整滑块值.这种行为是不可取的.

I have a UISlider as part of a view that is loaded into a UIScrollView with paging enabled. I've noticed an unexpected behavior. If the user tries to use the slider quickly (i.e. press and move) it "activates" the scroll view, causing the page to switch. However, if your press and hold for a second the slider "activates" and you can then adjust the slider value. This behavior is undesirable.

当加载到 UIScrollView 时,使 UISlider 响应的最佳方法是什么?我考虑过添加一个拦截器"视图,它只会占用放置在滑块下方的触摸事件,但不确定这是否是最好的方法.

What is the best way to make the UISlider responsive when loaded into a UIScrollView? I've thought about adding a "blocker" view that just eats up touch events that is placed under the slider, but not sure if this is the best way to go about it.

推荐答案

让你的滚动视图检测你的滑块占据的区域的触摸(覆盖 hitTest:withEvent:,你可能需要子类 <代码>UIScrollView).如果检测到对所述区域的触摸,请告诉您的滚动视图立即将触摸传递给滑块.

Have your scroll view detect touches over the region occupied by your slider (override hitTest:withEvent:, you may need to subclass UIScrollView). If a touch over said region is detected, tell your scroll view to immediately pass the touch to the slider.

这篇关于UISlider 和 UIScrollView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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