本文介绍了释放触摸时 UISlider 太敏感的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 UISlider 上释放触摸时,滑块的值会发生轻微且无法控制的变化.它非常敏感,甚至当手指从屏幕上松开时它甚至会发生变化.我怎样才能实现用户可以毫无问题地设置他想要的值?

When releasing the touch on a UISlider the value of the slider changes slightly and uncontrollably. It's so sensitive that it even changes when just releasing the finger from the screen. How can I achieve that the user can set a value he wants without problems?

这就是我创建 UISlider 的方式:

That's how I create my UISlider:

UISlider *slider = [[UISlider alloc] initWithFrame: CGRectMake(100.0, 100.0, 200.0, 40.0)];
slider.minimumValue = 0.0;
slider.maximumValue = 100.0;
[slider addTarget: self action: @selector(sliderChanged:event:) forControlEvents:UIControlEventAllEvents];
[slider setValue: 50.0 animated: NO];

推荐答案

您正在为所有事件注册它.只为您的活动制作它

You are registering it for all events. Make it for your event only like

[slider addTarget: self action: @selector(sliderChanged:event:) forControlEvents: UIControlEventTouchDragInside];

这篇关于释放触摸时 UISlider 太敏感的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 21:12