I am trying to work with UIStepper
to increment or decrement an integer,
but both "-" and "+" increase the integer! How can I recognize the "+" and "-" button?
In the UIStepper
header file there are two UIButton
s:
UIButton *_plusButton;
UIButton *_minusButton;
for example :
- (IBAction)changeValue:(id)sender
{
UIStepper *stepper = (UIStepper *) sender;
stepper.maximumValue = 10;
stepper.minimumValue = 0;
if (stepper)
{
integer++;
[label setText:[NSString stringWithFormat:@"%d",integer]];
}
else
{
integer--;
[label setText:[NSString stringWithFormat:@"%d",integer]];
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…