Ios UIDatePicker块分钟滚动

Ios UIDatePicker块分钟滚动,ios,uidatepicker,Ios,Uidatepicker,我知道不能将UIDatePicker上的minuteInterval设置为30以上,但是否可以阻止分钟滚动 这样,用户只能滚动小时,但分钟将保持在开始时设置的状态。每次更改后,您可以将分钟重置为0或任何您想要的值 [self.myDatePicker addTarget:self action:@selector(myAction:) forControlEvents:UIControlEventValueChanged];

我知道不能将
UIDatePicker
上的
minuteInterval
设置为30以上,但是否可以阻止分钟滚动


这样,用户只能滚动小时,但分钟将保持在开始时设置的状态。

每次更改后,您可以将分钟重置为0或任何您想要的值

[self.myDatePicker addTarget:self
                      action:@selector(myAction:)
            forControlEvents:UIControlEventValueChanged];


- (void)myAction:(id)sender
{
    NSDate *currentDatePickerDate = self.myDatePicker.date;
    NSDate *dateWithoutMinutes = // use NSDateComponents to create a date that's equal to currentDatePickerDate except the minutes
    [self.myDatePicker setDate:dateWithoutMinutes animated: NO];
}
但是,您最好只显示一个
UIPickerView
来选择小时,并在小时旁边显示分钟作为常量


-[UIDatePicker minuteInterval]
设置为60也可以执行您想要的操作。

每次更改后,您可以将分钟数重置为0或任何您想要的值

[self.myDatePicker addTarget:self
                      action:@selector(myAction:)
            forControlEvents:UIControlEventValueChanged];


- (void)myAction:(id)sender
{
    NSDate *currentDatePickerDate = self.myDatePicker.date;
    NSDate *dateWithoutMinutes = // use NSDateComponents to create a date that's equal to currentDatePickerDate except the minutes
    [self.myDatePicker setDate:dateWithoutMinutes animated: NO];
}
但是,您最好只显示一个
UIPickerView
来选择小时,并在小时旁边显示分钟作为常量


-[UIDatePicker minuteInterval]
设置为60也可以执行您想要的操作。

是否会在某个时间启用分钟?它会永远被禁用吗?@hossamghareb的可能副本它应该被禁用,因为时间视图是打开的,下次我打开视图时,可以将它设置为启用状态。@Harikrisnant我不需要将唯一可用的分钟数设为00,只需要将它们阻止,另外,滚动后将其设置为0的方法对用户不友好使用自定义UIPickerView(小时)和自定义UIPickerView(分钟)如何,您可以轻松启用/禁用分钟选择器何时启用分钟?它会永远被禁用吗?@hossamghareb的可能副本它应该被禁用,因为时间视图是打开的,下次我打开视图时,可以将它设置为启用状态。@Harikrisnant我不需要将唯一可用的分钟数设为00,只需要将它们阻止,另外,滚动后将其设置为0的方法对用户来说并不友好。使用自定义UIPickerView(小时)和自定义UIPickerView(分钟)如何,您可以轻松启用/禁用分钟选择器