簡體   English   中英

當用戶從日期選擇器中選擇日期時,如何在下拉列表中獲取一周中的特定日期?

[英]How to get the particaular day of week in a dropdown when the user selects a date from date picker?

當用戶從日期選擇器中選擇日期時,如何從下拉列表中獲取一周中的特定日期?

我想讓用戶選擇日期drom datepicker。 在下一個按鈕中,我有一天字段,其中包含一周中的天數列表。

我想在用戶點擊日期按鈕時顯示datepicker中所選日期的特定日期。 Plz幫我?????

嘗試這個

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

這個鏈接描述了如何使用日期時間選擇器。 對不起,以前的答案是針對其他語言的

http://www.dosomethinghere.com/2010/11/21/iphone-date-and-time-picker-view/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM