Hi all, I've got a UIDatePicker in a separate View Controller and is re-used throughout my app. I want to switch the UIDatePickerMode depending on whether a date input or time input is required. How do i switch the UIDatePickerMode programmatically? I've tried the below but it does not appear to work, the picker maintains it's default mode:
EDIT:
I've narrowed it down a bit. When i first initialise the date picker it maintains its default mode. Only afterwards does it allow me to change:
So the above will not change the mode when it does initialise the control but will do afterwards
Code:
picker.datePickerMode = UIDatePickerModeTime;
picker.datePickerMode = UIDatePickerModeDate;
EDIT:
I've narrowed it down a bit. When i first initialise the date picker it maintains its default mode. Only afterwards does it allow me to change:
Code:
if (dateTimePicker == nil)
{
dateTimePicker = [[DateTimePicker alloc] initWithNibName:@"DateTimePicker" bundle:nil];
dateTimePicker.delegate = self;
}
dateTimePicker.picker.datePickerMode = UIDatePickerModeTime;
[dateTimePicker showPicker];
So the above will not change the mode when it does initialise the control but will do afterwards
Last edited by a moderator: