UISlider and UIScrollView(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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:UISlider 和 UIScrollView


- android 4中的android RadioButton问题 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01