Simulating UIDatePicker date pick for testing - ios

I'm using a combination of XCTest and OCMock for testing and I'd like simulate a user selecting a date from a UIDatePicker. Is there any way of doing this other than setting the date property?

If you want to create a UIDatePicker for selecting the date then The following tutorials will help you.
https://stackoverflow.com/a/11198489/2869784
http://www.techotopia.com/index.php/Using_the_iOS_7_UIPickerView_and_UIDatePicker_Components

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.

islamicUmmAlQura UIDatePicker is not working properly

I am using islamicUmmAlQura UIDatePicker while developing iOS application as shown in the following
picture
and I have TWO problems summarised as follows:
1- The date that appears in the text field is gregorian while my UIDatePicker is islamic (Hijri) see figure
2- Sometimes the days in the Textfields are above normal! see figure
I have an extension on github to convert dates. Have a look. mine is persian date so you just need to replace the below code with mine inside the extension:
datePicker.calendar = Calendar(identifier: .islamicUmmAlQura)
[https://github.com/Fridday/PersianDatePicker][1]

UIDatepicker display future years with ' ---'

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.

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

iOS - Change Language for UIDatePicker by locale

I'm creating the app in "Herbrew" language. (Language of IPhone can be anything, but my app runs only in Herbrew).
In iOS for UIDatePicker, we have a property "locale" which will change the language that it is displaying. But in iOS5, the property is deprecated. How can I achieve it now?
Unfortunately, you cannot achieve this, not even with the calendar trick described by Martin Ulrich.
I've struggled with the same problem myself and after a long research, I found out the bitter truth: the only way to change the localization of the UIDatePicker is to change the device's language.
If the user will have the app's language as Hebrew, everything will be alright. If not, there's nothing you can do, except maybe create your own date picker. Sorry
You can set the calendar property of the UIDatePicker to [NSCalendar currentCalendar]

Resources