16

我已将 UISlider 设置为响应值更改事件:

[customSlider addTarget:self action:@selector(sliderMove:) forControlEvents:UIControlEventValueChanged];
[customSlider addTarget:self action:@selector(sliderStart:) forControlEvents:UIControlEventTouchDown];
[customSlider addTarget:self action:@selector(sliderEnd:) forControlEvents:UIControlEventTouchUpInside];

我想将滑块动画到用户上次使用视图时离开的位置。我这样做:

[customSlider setValue:position animated:YES];

一切正常,除了,我建立了一个挂在滑块“旋钮”上的“标签”,以便用户在移动滑块时可以看到值。在 UIControlEventValueChanged 调用“sliderMove”方法时设置“标签”的位置。

使用[slider setValue:position animated:YES]滑块移动时,但事件不会触发。

是否有我可以参加的代表或涵盖这种情况的活动?

感谢您提供的任何帮助:)

4

1 回答 1

30

听起来像一个错误,尝试通过调用来解决这个问题

[slider sendActionsForControlEvents:UIControlEventValueChanged];

在您以编程方式设置值之后。

于 2010-05-12T17:13:50.027 回答