textfield输入中文,未确定具体字时,如何获取输入框中的汉字拼音

来源:互联网 发布:阿里云服务器重定向 编辑:程序博客网 时间:2024/05/05 03:36
1.给uitextfiled增加一个 消息处理:

[mInputField addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];

2.在textFieldDidChange中,就可以接收到,所有的输入,但是需要将选中态时的拼音排除掉。

UITextRange *selectedRange = [textfield markedTextRange];

NSString * newText = [textfield textInRange:selectedRange];

0 0
原创粉丝点击