cagreen
cagreen

Reputation: 1625

iPhone UITextField mask

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?

Upvotes: 2

Views: 2089

Answers (1)

TechZen
TechZen

Reputation: 64428

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.

Upvotes: 3

Related Questions