zoukankan      html  css  js  c++  java
  • 设置UITextField中能输入的最大的字数

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

    {

        if ([string isEqualToString:@" "]){

            return YES;

        }

       
        NSString * aString = [textField.text stringByReplacingCharactersInRange:range withString:string];

        if (self.searchTextField == textField)

        {

            if ([aString length] > 5) {

                textField.text = [aString substringToIndex:5];           

                UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil

                                                                 message:@"超过最大字数不能输入了"

                                                                delegate:nil

                                                       cancelButtonTitle:@"Ok"

                                                       otherButtonTitles:nil, nil];

                [alert show];

                [alert release];

                return NO;

            }

        }

        return YES;

     

    }

  • 相关阅读:
    解决vue项目route使用history模式,tomcat部署刷新url 404问题
    更新
    Mac Anaconda 安装
    Mac python 环境配置
    Mac Python PyQt5 环境搭建
    Python 百分比计算
    Python __init__.py 文件使用
    Python redis 简单介绍
    python Django 创建应用
    python Django 项目创建
  • 原文地址:https://www.cnblogs.com/liuxp1990/p/3503129.html
Copyright © 2011-2022 走看看