• 怎样计算,遗留,


    - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string

    {

        NSString *signText;

        if (!textField.markedTextRange) {

     

            signText = [textField.textstringByTrimmingCharactersInSet:[NSCharacterSetwhitespaceAndNewlineCharacterSet]];

            

            int calculateLength = 0;

            int subStringTo = 0;

            int beforeIndex = 0;

            for (int i = 0; i< signText.length; i++) {

               char mChar = [textField.text characterAtIndex:i];

                if ((mChar > 'A' && mChar < 'Z') || (mChar >'a' && mChar < 'z')) {

                    if (i != beforeIndex + 1) {

                        calculateLength ++;

                    }

                    beforeIndex = i;

                }else{

                    calculateLength ++;

                }

                

                if (calculateLength == 10) {

                    subStringTo = i;

                }

                TTLog(@"-%c",mChar);

            }

            if (calculateLength > 10) {

                textField.text = [signText substringToIndex:subStringTo];

            }

    //        if (signText.length > 10) {

    //            textField.text = [signText substringToIndex:10];

    //        }

        }

        returnYES;

        

     

    }

  • 相关阅读:
    OpenWrt VTun Client
    LibreSpeed install on centos
    信号频道带宽、符号率、速率对应关系
    DVB相关标准
    Cisco Switch STP
    TROUBLESHOOTING MULTICAST ROUTING
    企业ERP核心模型与云计算生态
    Istio介绍(1)
    ServiceMesh案例
    Jenkins流水线发布实现CICD到Kubernetes
  • 原文地址:https://www.cnblogs.com/guligei/p/3490125.html
Copyright © 2020-2023  润新知