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 和大家交流

  • 相关阅读:
    脚本添加crontab任务
    docker mysql8 注意
    使用 logrotate 清理日志
    腾讯云cos对象在线显示
    快速部署私人git服务--基于docker化Gogs
    grep 使用
    vsftpd 新增虚拟用户
    unistd.h
    ffmpeg
    H264视频压缩算法
  • 原文地址:https://www.cnblogs.com/supercheng/p/2789677.html
Copyright © 2011-2022 走看看