문제

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?

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];

다른 팁

Try changing it to this instead:

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

And if all you want is to trigger the target only when the finger is lifted, try setting continuous property of the UISlider to NO.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top