0

我有NSDatePicker一个关联NSButton,按下时将当前日期更改为“今天”。

但是:当日期当前是 2014 年 1 月 4 日,并且我使用内置箭头按钮切换到不同的月份而不更改实际选择的日期时,似乎没有办法让日历刷新。这是该问题的视频:

问题视频: https ://www.dropbox.com/s/ay7fljnoyxb06ua/Calendar%20Test%20Video.mov

有关示例,请参见随附的示例项目。重现:

  1. 点击“今天”
  2. 单击右箭头按钮以切换到不同的月份(不选择实际日期)
  3. 点击“今天”

NSDatePicker如果您以编程方式选择的日期不在当前查看的月份中,并且它切换的日期也在不同的月份中,则似乎无法刷新。

但是,日期选择得当。如果您使用按钮选择日期,然后手动浏览回正确的月份,则日期已被选择。但日历永远不会自动显示该月,除非您切换的日期当前查看的月份。

示例项目: https ://www.dropbox.com/s/tnpox2mt5f5z2nb/CalendarTest.zip

4

1 回答 1

2

I would file this as a bug against the API since there are no methods in the class that suggest you'd have to ask it to refresh manually (I'd assume setting the selected date would automatically display the proper range to show that selection).

As a work-around, you might try asking it to display ( -setNeedsDisplay:YES ) or manually twiddling its min/max range after setting the date, then setting it back to unlimited immediately after. Maybe that'll kick-start it into displaying the correct range for the selected date.

于 2014-01-04T17:30:40.313 回答