Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UISlider Finished Changing

Tags:

ios

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];
}
like image 792
Nicholas Gibson Avatar asked Mar 06 '26 09:03

Nicholas Gibson


1 Answers

You have already added one target/action pair for UIControlEventValueChanged, all you need to do is call addTarget:action:forControlEvents: again with a different selector and a control event of UIControlEventTouchUpInside (or any other that you're interested in).

like image 125
Wain Avatar answered Mar 08 '26 01:03

Wain



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!