UIDatepicker display future years with ' ---' - ios

iOS UIDatepicker shows '---' for future years. How to achive this in iOS. It will show only till current year and after that it shows '---'. I seen this when we adding any contact in our iPhone contact app, where there is field to addBirth. You can see that.
Please see screen shot.

The UIDatePicker doesn't have option for this.
Available Picker modes: time, date, dateAndTime, countDownTimer.
You can set maximumDate value, so that date after that can't be selected using UIDatePicker.
If you need to fulfil the exact need, you have to create custom UIPickerView with multiple component and Manage all things. NB: This could be messy.

Related

Swift Date Picker hide days of the week

I use standard Apple UIDatePicker with inline style. How can I hide the days of the week?
I did not find the method on the Internet
screenshot
Have you tried to change the Mode from Attributes Inspector ? By default the mode is set to Date and Time. You need to change it from there or you can create your own CustomDatePicker to display only the months or only the years.
Take a look to this CustomDatePicker example here:
https://github.com/Anandsan/UICustomDatePicker
Or you can use a UIPickerView to set all the months and another UIPickerView to set the years you want to display and after that you can extract the selected values and to use them in your app.

24h UIDatePicker does not offer 24 hours in certain circumstances

In my app, users can pick a "duration". I am using a UIDatePicker with datePickerMode set to time for this.
In order to pick 0-24h, I set the date picker locale to e.g. NL like explained here.
Because I want to show the picker in a list, I use compact for the preferredDatePickerStyle
In order to make it easier for the user to pick a duration, I set minuteInterval to 5
Now, when using this on a device that has 12h time display in the iOS settings, this causes the expanded date picker to only offer hours from 1-12, instead of 0-23.
Interestingly, this problem does not occur when the device is set to 24h time display or I am using any other value for the minuteInterval (e.g. 10) or I am using a different preferredDatePickerStyle (e.g. inline)
Is this an iOS bug and is there any workaround?

How to DatePicker with Year Month day time

How to get DatePicker |Year|Day Date Month|Time Min|Second|AM PM| ?
Default DatePicker Showing its showing |Day Date Month | Min | Seconds|
Date picker is a very high level component and does not allow explicit setting of display in any way. There are properties you can play around with such as datePickerMode and locale. For your case I guess you should find a correct locale.
This is not advised though. The thing is that locale is set automatically or it should be set to whatever makes sense to user which world-wide depends on the user. If you override this functionality you will most likely confuse users.
Anyway if you can't get the result you want with date picker you will have to user a normal picker view and manage sections and rows yourself.
You can get some how close to your desired requirement by setting DatePicker's datePickerMode property
myDatePicker.datePickerMode = .dateAndTime
see the more available datepicker mode .here
UIDatePicker takes device Time format. If you have 24 hour Date format selected in your device, the UIDatePicker will not show AM/PM and show the time in 24hr. format. So you have to change the Time format of the device to 12 hour format. We can not set the time format of the UIDatePicker.

How to have this date picker mode?

The reminders app uses this date picker mode of "wed, april 20" and the hours, but in my app, I'd like to have only the "wed, april 20" format. I'm using the normal Date mode (date - month - year) right now, but as it is not showing the date's name its a bit confusing. Is this a normal mode that I can use (the reminders app mode)?
Taking the flow of the question, I also wanna ask something: to set the date picker as a text field's input view I need to create an action of the text field and use textField.inputView = datePicker
Right?
Reply to the questions you know, or both, thanks in advance!
The date format of the UIDatePicker can only be set using it's mode property and it doesn't allow a lot of flexibility, like displaying a week day. If you want to achieve this you either have to make your own date picker using a UIPickerView, or find some of the third-party components available online.
You can change datePicker mode as
[picker setDatePickerMode:UIDatePickerModeDateAndTime];

When will gestures to select specific values from DatePickers and ValuePickers become possible with the new UI Testing framework in iOS 9?

Right now, I am able to set accessibility labels and identifiers for different picker wheels in my application so that the recorder can pick up when I tap these picker wheels, and I am able to swipe up and down to modify the values, but I am unsure if there is a way for me to specify an exact value to select in these pickers. I am currently running XCode 7 Beta 5 and here is the following code I currently have:
//Expands the cell with the DatePicker
XCUIApplication().tables.staticTexts["Due Date"].tap()
//Modifies the Month, Day, and Year picker wheels.
XCUIApplication().tables.cells["dueDate"].pickerWheels["August"].swipeUp()
XCUIApplication().tables.cells["dueDate"].pickerWheels["19"].swipeUp()
XCUIApplication().tables.cells["dueDate"].pickerWheels["2015"].swipeUp()
As I mentioned, this code works fine, but I kind of have to guess at what the end result would be based upon the current start date (which is the current date, in our app) instead of being able to set the date to a known value.
Has anybody else been running into this same issue? If so, are there any known work arounds? It seems like the set of gestures that the API can mimic are still fairly limited.
Per this post starting in Beta 6 you should be able to do something like this...
app.datePickers.pickerWheels["2015"].adjustToPickerWheelValue("2005")

Resources