当用户从日期选择器中选择日期时,如何从下拉列表中获取特定的星期几?
我想让用户选择一个日期 drom 日期选择器。在下一个按钮中,我有天字段,其中包含一周中的天数列表。
当用户单击日期按钮时,我想从日期选择器中显示所选日期的特定日期。请帮帮我??????
尝试这个
NSDate *today=calendarPicker.date;
NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *components = [gregorian components: (NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit) fromDate: today];
components.year = [textfield.text intValue]; // Here value for year is fetched from a text field control. Similarly other values like month, date, hour or minute can be changed.
[calendarPicker setDate: [calendar dateFromComponents:components] ]; // Update the date picker control.
[calendar release];