0

As the user is typing into a text field, is there a way to have the string conform to a format. So as the user is typing his string in every 5th character is proceeded by a hyphen in the UITextField that the user can see as they type.

Any help would be greatly appreciated.

tinhead
  • 387
  • 2
  • 10
  • 29

1 Answers1

0

Have a look at this answer! I think it's what you're looking for.

Community
  • 1
  • 1
Julian
  • 1,570
  • 2
  • 21
  • 36
  • How would I use that on the UITextField I want to format? someone else has suggested pretty much the same thing.. but I wasn't sure how to actually get it to work on the TextField I wanted to format. – tinhead Apr 27 '11 at 22:49
  • When the method gets called you can get and set the TextField's text (given you've created an IBOutlet for it). From within this method you can do any formatting :) (like, for example, getting the text, inserting a hyphen before every 5th character, setting the new text) – Julian Apr 27 '11 at 22:55
  • I have defined my UITextField in my header file and given it an IBOutlet and then linked it up in interface builder.. But it dosn't format. Is there something I am missing in regards to setting up the connection between this method and the textfield. Thanks for the help thus far. – tinhead Apr 27 '11 at 23:02