super_chen 发表于 2013-1-4 01:37:05

UITextView 打入中文时,输入拼音会调用 textViewDidChange: 回调的解决方案

<div id="cnblogs_post_body">做项目的时候需要用到UITextView
输入法设置为中文时,我想输入中文“有”,我输入一个字母y的时候,一下回调会被调用

-(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text


- (void)textViewDidChange:(UITextView *)textView
目前的解决方案是用以下方式做适配
-(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{
    if (textView.text.length !=0) {
      int a = ;
      if( a > 0x4e00 && a < 0x9fff)
      {
            NSLog(@"汉字");//做相应适配
      }
      else
      {
            NSLog(@"english");//做相应适配
      }
    }
    returnYES;
}
如有疑问可以进IOS中高级开发群:118623167 和大家交流
页: [1]
查看完整版本: UITextView 打入中文时,输入拼音会调用 textViewDidChange: 回调的解决方案