开发者

iPhone UITextField mask

开发者 https://www.devze.com 2022-12-18 20:11 出处:网络
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 enter开发者_开发问答ing text.

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 enter开发者_开发问答ing text.

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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号