gpt4 book ai didi

iphone - 当用户从日期选择器中选择日期时,如何在下拉列表中获取特定的星期几?

转载 作者:行者123 更新时间:2023-11-29 11:09:15 24 4
gpt4 key购买 nike

当用户从日期选择器中选择日期时,如何从下拉列表中获取特定的星期几?

我想让用户从日期选择器中选择一个日期。在下一个按钮中,我有天字段,其中包含一周中的天数列表。

我想在用户点击日期按钮时显示日期选择器中选定日期的特定日期。请帮助我?????

最佳答案

试试这个

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

关于iphone - 当用户从日期选择器中选择日期时,如何在下拉列表中获取特定的星期几?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12261781/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com