views:

303

answers:

1

Is there built in support for input masks in UITextField? I could apply formatting after the text has been entered, but I'd like it to be there as the user is entering text.

If there is no build in support, how can tis be achieved?

+1  A: 

The iPhone doesn't support formatters like Cocoa does. You have to manage input filtering in the UITextFieldDelegate method:

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string

This method is called before any text appears in the field.

TechZen