博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
UITextField,UITextView字数限制
阅读量:7249 次
发布时间:2019-06-29

本文共 922 字,大约阅读时间需要 3 分钟。

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;    }}

 

转载地址:http://daqbm.baihongyu.com/

你可能感兴趣的文章
什么时候开始不算晚?
查看>>
页面无阻塞加载研究
查看>>
java.util.concurrent包(1)——synchronized和lock
查看>>
Android Root Source Code: Looking at the C-Skills
查看>>
shell 脚本简介
查看>>
【Transact-SQL】一句SQL删除重复记录
查看>>
bash编程之算术运算
查看>>
服务器类型
查看>>
安装VIM8和vim-go插件
查看>>
安装SCCM2012 R2
查看>>
CentOS6.5 NFS服务器的安装与基本参数
查看>>
I/O多路转接之select
查看>>
让有些“-l”链接静态库,而另一些链接共享库?
查看>>
使用Webstorm操作git
查看>>
uboot移植之start_armboot()函数分析
查看>>
移动办公是不能阻挡的未来办公趋势
查看>>
docker简单介绍及安装
查看>>
DNS服务(1)基本概念详解
查看>>
Redhat7DNS搭建
查看>>
python之rabbitMQ
查看>>