我可以限制一个UITextField的字符集吗? [英] Can I limit the character set for a UITextField?

查看:109
本文介绍了我可以限制一个UITextField的字符集吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个位图字体,它没有每个字符,如重音字符(éîü等)或符号如¥或©,我用来显示用户名在一个Highscore表中一个游戏。

I have a bitmap font which which doesn't have every single character, such as accented characters (é î ü etc) or symbols such as "¥" or © which I'm using to display usernames in a Highscore table for a game.

是否可以将UIKit键盘限制为特定字符,或只允许UITextField中的某些字符?还是我要滚动我自己的输入机制?

Is it possible to limit the UIKit keyboard to certain characters, or only allow certain characters in the UITextField? Or will I have to roll my own input mechanism? I'm thinking and old school, Arcade style, one letter at a time "thing" would be ok.

推荐答案

你可以尝试使用以下UITextFieldDelegate方法:

You could try using the following UITextFieldDelegate method:

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

这篇关于我可以限制一个UITextField的字符集吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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