zoukankan      html  css  js  c++  java
  • UITextView 打入中文时,输入拼音会调用 textViewDidChange: 回调的解决方案

    做项目的时候需要用到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 和大家交流

  • 相关阅读:
    nyoj 17 单调递增最长子序列
    nyoj 18 The Triangle
    nyoj 712 探 寻 宝 藏
    nyoj 61传纸条(一)
    nyoj 269 VF
    nyoj 44 子串和
    nyoj 252 01串
    nyoj 42 一笔画问题
    nyoj 756 重建二叉树
    Table 样式设置
  • 原文地址:https://www.cnblogs.com/supercheng/p/2789677.html
Copyright © 2011-2022 走看看