简体   繁体   中英

How to use rangeDataMode correctly in NSDatePicker?

In a Mac OS X app, I try to set the datePickerMode to use rangeDataMode because I do want to pick up a range of dates (a start date & an end date).

let datePicker = NSDatePicker()
datePicker.datePickerMode = .rangeDateMode

However, the NSDatePicker still works like singleDateMode . I can only specify one date in that NSDatePicker .

How to use rangeDataMode correctly?

As far as I can tell, .rangeDateMode only seems to have an effect when datePickerStyle is set to .clockAndCalendarDatePickerStyle , since as you have noticed, the default "stepper" style doesn't have any obvious UI for selecting a range rather than an individual date. Try running the date picker in calendar style, and you should be able to select ranges.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM