0

I want to make a single UITextField that displays the format 00:00.00 where the : and . are permanently set. So the user will tap the text field to edit it, and instead of the textfield going blank, I would like it to be __:__.__ (the underscores are blanks) and the user can type two numbers for the minutes, automatically shift to the seconds, type two numbers, and then autoshift to the milliseconds. How can this be done?

Kyle Beard
  • 604
  • 5
  • 18
  • 1
    your best bet will be to create three text fields and add two uilabels between them : and . – Sam B Jul 16 '14 at 16:20
  • Okay thanks. That's a lot of repetitive code but I guess its the most practical. Is there a way to automatically shift from one text field to the next when a certain amount of characters are entered? – Kyle Beard Jul 16 '14 at 16:22
  • 1
    if I were you, I will not use uitextfield for this purpose. You have way too many limitations i.e. you have to write tons of code to stop user from entering alpha characters, then limit to 2 characters and then jump the cursor somehow to next text label. Use a UIPickerView instead and show formated dated once the user selection is done . Example - http://stackoverflow.com/questions/10999575/uipickerview-that-looks-like-uidatepicker-but-with-seconds/11007461#11007461 – Sam B Jul 16 '14 at 16:28

1 Answers1

0

Alternatively, you could just use a UIDatePicker:

UIDatePicker *picker = [[UIDatePicker alloc] initWithFrame:self.view.frame];
[self.view addSubview:picker];

This is also available for drag-and-drop in the storyboard.

michaelsnowden
  • 6,031
  • 2
  • 38
  • 83