UIDatepicker中的日期无法正常显示

时间:2013-05-29 16:13:46

标签: iphone ios objective-c nsuserdefaults uidatepicker

我有UIDatepicker。我几乎没有问题要求

1.)当我点击UIButton时,datepicker中的日期会返回到最小值,因为我已经给出了最大值和最小值。在执行该功能时,datepicker中的日期似乎是非突出显示的方式![在此处输入图像描述。下面提到的链接显示日期如何出现在datepicker

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];
    }

}

0 个答案:

没有答案