Is it possible to set in UIDatePicker, date/time frames selectively? for example: show only Mondays from 8am to 4pm ?
Unfortunately, you cannot do this with standard UIDatePicker. Instead you should build your own custom date picker based on UIPickerView.
Related
I want to allow user to select only given date from API and other date should be un-clickable or disable.
As I can check in SWIFT UIDatePicker only providing minimum date and maximum date selection but my requirement is to enable random date.
How to set date formate to the UIDatePickerView for month MMM using locale can we achieve it?
Is there away to set three char of month to UIDatePickerView
No, you can't set a specific format on a date picker. You can set the locale (which defaults to the user's current locale) which affects the format.
If you truly want a date picker with a specific format (bad idea because it will likely confuse users), you will need to create your custom date picker using UIPickerView.
I have a UIDatePicker with a minimumDate and maximumDate set. The default UI of the date picker shows all dates, including those before the minimum and after the maximum. If the user spins to an out-of-bounds date, the picker does spin back - but this is not a great user experience. Can I make it so that the picker simply doesn't display out-of-bounds dates?
In my case, this is particularly important because my app deals with historic events. The date picker starts at the current date and allows users to spin back in time. It's faintly ridiculous in this situation to show tomorrow's date below the current date.
Just Making Calendar app which i have the same requirement as IOS calendar. In that All Day toggle Changes To Different Date Formatting And DatePicker Style is also different. How can i deal with that?.
Use NSDateFormatter and when user change the toggle update format of date using Date formatter and load new format in Picker.
you have option to create another picker otherwise you have to define condition on the picker delegate to show the new date format or your required format .
when you first time open the picker than the content would load on to the picker may be there is a chance when you pass the command to change format than the picker is still showing previous content than you need to reload the picker content to update the picker content value and to show the updated format type content.
may this could help you.
I have a date picker that is set to not allow users to pick future dates. It's maximum date is set for the current time on viewDidLoad.
dateDatePicker.maximumDate = NSDate()
But I've been noticing a bug. Today until midday the maximum date was yesterdays date. But now, after midday it is showing todays date.
The way I implemented it: The date picker is shown and hidden with alpha when user wants to use it. So I am setting the maximum date not every time the picker is shown but once it loads the view it is in.
So I am not sure if this is a bug?
Is it has to do with timezones?
Or has to do with the fact that I am only calling dateDatePicker.maximumDate once when they view loaded and that could have happened days ago?
Or if I should reset the maximumDate every time I show the datePicker?
Yes, you should almost certainly set the maximum date each time you show the date picker.
If you set the maximum date on a previous day and then never updated it nor closed the view controller the it wouldn't change.
Set it in viewWillAppear, not viewDidLoad.
If that doesn't work, use NSCalendar and NSDateComponents to build an NSDate which is 23:59 on the current date (fetch the MM/DD/YYYY from the current date as date components, then manually set the time to 23:59. That should work.