在的UIDatePicker显示不正确的日期(Dates in UIDatepicker not d

2019-10-18 05:19发布

我的UIDatePicker。我有几个疑问问

1)当我点击上的UIButton在日期选择器获取retuns到最小值,因为我已经给了最高和最低值的日期。 在这样做时功能在日期选择器的日期似乎是不突出的方式![请在此输入的形象描述。 下面提到的链接显示的日期是如何出现在日期选择器

http://postimg.org/image/7mlxiq6sz/

-

(IBAction)notificationButtonChanged:(UIButton *)control
{

    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

    if (control.tag == 1)
    {
        self.selectedButton = control.tag;

        NSDate *date1  = [defaults objectForKey:@"morningTimeKey"];
        if(!date1) date1 = [NSDate date];

        components = [gregorian components: NSUIntegerMax fromDate:date1];

        [components setHour:12];;
        [components setMinute:00];

        NSDate *startDate = [gregorian dateFromComponents:components];

        [components setHour:14];
        [components setMinute:00];

        NSDate *endDate = [gregorian dateFromComponents:components];

        [userTimePicker setDatePickerMode:UIDatePickerModeTime];

        [userTimePicker setMinimumDate:startDate];
        [userTimePicker setMaximumDate:endDate];

        [userTimePicker setDate:date1 animated:YES];

        [userTimePicker reloadInputViews];
    }

}
文章来源: Dates in UIDatepicker not displaying properly