When selecting a range for two months start date highlighted for the dates outside month which doesnt look correct. I tried to change css classes but cannot achieve what I want. I know there is a class for days outside month but overriding it doesnt help.
I want a date picker like this one, with the month name in short format:
But this is what I get:
This has the full month name, which is not what I want.
I set date picker mode like this:
mydatepicker.datepickermode = datepickermode.date
but it's not working.
Embedded datePicker is not very flexible to adjust. The way to solve your issue is to create your own picker by using UIPickerView. You need to create a picker with 3 components and configure it depending on your wishes. But this way is a little bit annoying, because you need to keep in mind, that every month has it's own number of days. And don't forget also about 29th of February.
How do I get data picker to display and select the year also.
Currently I see the following but what I need is Year Mon Day HH MM
.datePickerMode = .date or .datePickerMode = .dateAndTime
both are dependant on locale... so different countries will see different potentially undesirable formats.
Swift Accessing year from UIDatePicker
You can customise UIPickerView though if you need to...
Can i customize UIDatePicker?
I am new to Swift. In my app, I have a date picker concept. My issue is when select date button, date picker is appearing fine suppose I select DEC 20 2015. My issue is when scroll date picker wheel very fast and press done button on my date picker tool bar date is not picking . If I open date picker I want to show previously selected date example DEC 20 2015. But it shows some other dates when I scroll faster.
var datePicker:UIdatePicker
func dateselcted()
{
var date:NSDate = NSDate()
datePicker.minimumdate = date
if cell.dateText.characters.count == 0
{
//If user not select any date I am showing current date and working fine
var dateOb:AnyObject =
datePicker.setdate(date ,animated:false)
}
else
{
// Suppose user select DEC 20 2015 storing this date in one object example below and working fine but it is fails when scroll datepicker wheel very fast then it is showing the other date how to show "DEC 20 2015 " when picker wheel scrolls fastly I want to show date what I selected
var dateOb:AnyObject = DEC 20 2015
datePicker.setdate( dateOb as nsdate ,animated:false)
}
}
A date picker only invokes it's action method when the wheels stop spinning. You don't get called continuously as the wheels spin from value to value.
It doesn't look like there is any facility to do what you want (get notified of value changes as the wheels in the date picker spin.)
Furthermore, I don't think the value of a date picker (or a regular UIPickerView) changes until it stops spinning, so it will still have it's old value if you start it spinning and click the button before it stops.
Are you waiting for the scrolling to stop before pressing your done button? That may be your issue.
This answer may have what you are looking for.
The delegate
pickerView:didSelectRow:inComponent:
is not called until the picker stops spinning. If you need to determine the selected row while spinning, you will need to write some logic to guess the state when done is pressed.
There is no way to select a date like you do and still expect the date picker picking your desired date automatically. The device does not know what we think. Normally, users won't press a button until they see that date gets selected. So, I think your concern is trivial.
You can first set datePicker.date to [NSDate date], then set datePicker.date to previously selected date. the OC code for you:
datePicker.date = [NSDate date];
datePicker.date = date;
It works for me, but I don't know why.
I want to display dates in UIImagePicker within a range, I have start date and I will select start date and end date should automatically appear for a week, dates from past one week should appear. i.e if start date is 10 and end date should be displayed as 3 and dates should be Populated between 10 to 3 which should be displayed in iOS.
just use the maximumDate and minimumDate properties of UIDatePicker