I’m using a UIDatePicker in UIDatePickerModeCountDownTimer to allow the user to select a duration.
If you set the timer interval to 5 minutes, the user will be able to select 0 hours : 0 minutes (which is bad; this is not allowed in iOS 5 or even in iOS 6 with a 1 minute interval).
Right now I’m fixing it by doing this on change:
-(void)timerValueChanged
{
int clockInterval = workoutTimePicker.minuteInterval * 60;
if (workoutTimePicker.countDownDuration < clockInterval) {
workoutTimePicker.countDownDuration = clockInterval;
}
}
But that makes the roller jump. How can I animate the roller?
There is currently no
setCountDownDuration:animated:so we have to usesetDate:animated:.We must create a
NSDateobject with current day/month/year to allow us to fill the minutes component, with your desired value, let’s say it’sworkoutTimePicker.minuteInterval:So with that new date, we just need to set the picker’s date: