做项目的时候需要用到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 = [text characterAtIndex:0];

        if( a > 0x4e00 && a < 0x9fff)

        {

            NSLog(@"汉字");//做相应适配

        }

        else

        {

            NSLog(@"english");//做相应适配

        }

    }

    returnYES;

}

如有疑问可以进IOS中高级开发群:118623167 和大家交流

相关文章:

  • 2021-08-22
  • 2022-01-22
  • 2021-10-10
  • 2022-12-23
  • 2021-12-05
  • 2022-12-23
  • 2021-07-25
猜你喜欢
  • 2022-12-23
  • 2021-05-29
  • 2022-12-23
  • 2021-11-17
  • 2022-12-23
  • 2022-01-02
  • 2021-05-22
相关资源
相似解决方案