A new digital input control Uistepper has been added to the iOS5, which can be entered in progressive quantities . Uistepper inherits from Uicontrol, and its main event is uicontroleventvaluechanged, which triggers this event whenever its value changes. It shows the following effects:
It mainly has the following properties
- Value currently represented by default 0.0
- MinimumValue minimum value that can be represented, default 0.0
- MaximumValue The maximum value that can be represented, default 100.0
- Stepvalue each increment or decrement of value, default 1.0
Set the above values, it is generally easy to use.
| 1234567 |
UIStepper *stepper = [[UIStepper alloc] init];stepper.minimumValue = 2;stepper.maximumValue = 5;stepper.stepValue = 2;stepper.value = 3;stepper.center = CGPointMake(160, 240);[stepper addTarget:self action:@selector(valueChanged:) forControlEvents:UIControlEventValueChanged]; |
Note: Above I set Stepvalue is 2, the current value is 3, the minimum value is 2. But if we click on "-", this is value will become 2 instead of 1. That is, each change is value±stepvalue, and then the final value is limited to the [Minimumvalue,maximumvalue] range.
There are several other control properties:
- Continuous controls whether the Uicontroleventvaluechanged event is continuously triggered. The default yes, which triggers the uicontroleventvaluechanged event every time a value change is pressed, or the Uicontroleventvaluechanged event is triggered only when the button is released.
- AutoRepeat controls whether or not the hold is automatically continuously incremented or decremented. Default yes.
- Wraps whether the control value loops within the [Minimumvalue,maximumvalue] interval. default No, when the maximum or minimum is reached, the button disable.
These control attributes are used only in special cases and are generally used with default values
iOS Uistepper controls