3

I have a slider that when it begins to change the values, another label shows up (lets the user see what they are doing). The only problem is that I need to know when the user has finished editing the slider so I can make that UILabel go away again. Is there a way to do this? The code below shows what I do when the sliders value begins to change. Thank you for you help!

- (IBAction)sliderValueChanged:(UISlider *)sender {
    tipPercentLabel.text = [NSString stringWithFormat:@"%.f", ([sender value] * 100)];
    tipPercentLabel2.text = [NSString stringWithFormat:@"%.f", ([sender value] * 100)];

    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:1.0];
    [tipPercentLabel setAlpha:0.3];
    [tipPercentLabel2 setAlpha:1.0];
    [UIView commitAnimations];


    [self performSelector:@selector(autoTipCalc) withObject:nil afterDelay:0.01];
}
4

2 回答 2

5

您已经为 添加了一个目标/动作对UIControlEventValueChanged,您需要做的就是使用不同的选择器和(或您感兴趣的任何其他)addTarget:action:forControlEvents:的控制事件再次调用。UIControlEventTouchUpInside

于 2013-06-24T07:42:55.053 回答
0

您可以像UIButon处理一样将目标添加到滑块UIControlEventTouchUpInside(也可以在外部进行)。可选地或替代地,您可以在每次值更改后延迟后执行选择器,以检查滑块值上次更改的时间,如果花费的时间足够长,则删除标签。

于 2013-06-24T07:42:54.523 回答