zoukankan      html  css  js  c++  java
  • UITextField,UITextView字数限制

    UITextField,UITextView字数限制

    主要是使用他们的两个代理方法

    //标题限制在 30个字以内
    
     - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
    {
            if (range.location>=30)
            {
                UIAlertView *alertNums = [[UIAlertView alloc]initWithTitle:@"输入提示" message:@"标题字数限制在30字以内!" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
                [alertNums show];
                return  NO;
            }
            else
            {
                return YES;
            }
       
    }
    //内容限制在100个字以内;
    
    - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
    {
        if (range.location>=100)
        {
            UIAlertView *alertNums = [[UIAlertView alloc]initWithTitle:@"输入提示" message:@"内容限制在100字以内!" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
            [alertNums show];
            return  NO;
        }
        else
        {
            return YES;
        }
    }
  • 相关阅读:
    科学计算器
    ASCII码表
    面试题(2)
    面试题(1)
    ACM/ICPC竞赛
    ACM/ICPC竞赛
    ACM-ICPC竞赛模板
    杭电题目分类(1)
    ACM/ICPC竞赛
    ACM/ICPC竞赛
  • 原文地址:https://www.cnblogs.com/cocoajin/p/3476649.html
Copyright © 2011-2022 走看看