In an application with more than one view controller, how can you setup a UIStepper so that it restarts from the last selected value when the button is pressed.
Currently if I move back and forth to my view with the Steppers, if I press the stepper button it resets the value in my label to its start default value.
I'd like it to increase/decrease from the last value selected by the user.
Thanks!
try:
-(void)viewDidLoad {
int number = [[NSUserDefault standardUserDefault] integerForKey:@"value"];
if(!number) { number = 1; };
yourStep.value = number;
}
-(IBAction)changeValue:(UIStepper *)sender {
double value = [sender value];
int myValue = (int)value;
[[NSUserDefault standardUserDefault] setInteger:myValue forKey@"value"];
}