我有一个 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
在 Xcode 4 的 Interface Builder 中滚动 UIScrollViewScrolling through UIScrollView in Interface Builder for Xcode 4(在 Xcode 4 的 Interface Builder 中滚动 UIScrollView)
创建类似于主视图的跳板Create springboard like main view(创建类似于主视图的跳板)
滑动删除嵌入在 UIScrollView 中的 UITableViewswipe to delete in a UITableView which is embeded in a UIScrollView(滑动删除嵌入在 UIScrollView 中的 UITableView)
检查 UIScrollView 中的滚动方向Check direction of scroll in UIScrollView(检查 UIScrollView 中的滚动方向)
UIScrollView 不滚动?UIScrollView Not Scrolling?(UIScrollView 不滚动?)
UIScrollView 如何从其子视图中窃取触摸?How does UIScrollView steal touches from its subviews?(UIScrollView 如何从其子视图中窃取触摸?)