To increase the slider value by 10
3 answers
Assuming the slider will increase / decrease in 10 steps ...
Connect the slider value changed in IB (or UIControlEventValueChanged
in code) to a method in your view controller, for example:
- (IBAction)sliderValueChanged:(id)sender {
int value = (int)[self.slider value];
int stepSize = 10;
value = (value - value % stepSize);
// Set the new value.
self.sliderValue = value;
}
self.sliderValue
is a separate integer property to keep track of the value (instead of changing the base value of the slider causing UI issues)
+6
source to share