只允许在 iPhone UITextField 中输入英文字符 [英] allow only to enter english characters in iPhone UITextField

查看:32
本文介绍了只允许在 iPhone UITextField 中输入英文字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想只允许用户输入英文字母和字符.如何防止用户输入英文以外的其他字符.

I want to allow user to enter only english alphabets and characters. How can i prevent user from entering other characters than english.

推荐答案

查看 UIKeyboardType - 有一个选项仅支持 ASCII (UIKeyboardTypeASCIICapable).

Check out UIKeyboardType - there is an option to support only ASCII (UIKeyboardTypeASCIICapable).

此外,UITextFieldDelegate 协议中有一些选项可以让您有选择地过滤输入.看看:

Also, there are options in the UITextFieldDelegate protocol that could allow you to selectively filter input. Take a look at:

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

这篇关于只允许在 iPhone UITextField 中输入英文字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆