UIDatePicker mode UIDatePickerModeCountDownTimer cannot select zero minutes

I use the mode UIDatePickerin UIDatePickerModeCountDownTimerwhich allows the user to select hours and minutes, but it will not allow the user to select zero hours and zero minutes. If the clock is set to zero and the user tries to select zero minutes, he automatically switches to 01.

I examined the documents, and nothing seems to allow me to do this without waiting for the user to create a selection. The problem with creating a custom selection element is that I am losing the title in the selection indicator (hours, minutes), and there seems to be no way to add them. I searched for an answer in the last 2 days! I cannot believe that UIPickerView does not have a property to set a title for indicators for each section.

Any help would be appreciated.

+3
source share
2 answers

If you decide to create a custom one UIPicker, you can use the method titleForRowto change the labels in each component (for example, “hours”, “minutes”, etc.).

- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component{
    if(component == 0){
        return [NSString stringWithFormat:@"Hours"];
    }else if (component == 1){
        return [NSString stringWithFormat:@"Minutes"];
    }
}
+2

, . , . , .

, - . 5 . 0 . , 0. , 1 , 0.

, , 0 , 1 0 . , . .

+1

Source: https://habr.com/ru/post/1771102/


All Articles