Domanda

I need a UIDatePicker or UIPickerView with the following date format:

yyyy-MM-dd HH-mm

Do I have to create it ? or is there some pickerStyle or pickerMode that implements it?

È stato utile?

Soluzione

You can do this simply by using a UIDatePicker and then set the pickerMode for it. Since, you need both Date as well as Time, all you have to do is set the mode to UIDatePickerModeDateAndTime

UIDatePicker *datePicker;
timePick.datePickerMode =UIDatePickerModeDateAndTime;

The following is provided in the Apple documentation for the above mode-

The date picker displays dates (as unified day of the week, month, and day of the month values) plus hours, minutes, and (optionally) an AM/PM designation. The exact order and format of these items depends on the locale set. An example of this mode is [ Wed Nov 15 | 6 | 53 | PM ].

EDIT:

In your case, I think the only option you have is to implement two UIDatePickers, one with mode set as UIDatePickerModeDate and another with UIDatePickerModeTime. Then, you can concat them both into an NSDate.

Hope this helps!!

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top