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;
        }
    }
  • 相关阅读:
    Spring IoC
    Java软件安装
    Struts(一)
    Struts(二)
    Hibernate(六)
    Hibernate(五)
    Hibernate(二)
    Hibernate(四)
    Hibernate(三)
    Hibernate(一)
  • 原文地址:https://www.cnblogs.com/cocoajin/p/3476649.html
Copyright © 2011-2022 走看看