UITextField,UITextView字数限制

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

//标题限制在 30个字以内

 - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
if (range.location>=)
{
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>=)
{
UIAlertView *alertNums = [[UIAlertView alloc]initWithTitle:@"输入提示" message:@"内容限制在100字以内!" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
[alertNums show];
return NO;
}
else
{
return YES;
}
}

最新文章

  1. scrapy爬虫笔记(二)------交互式爬取
  2. 使用cordova插件barcodescanner遇到的坑
  3. 使用servers 启动项目时 ,一直处于启动中, 最后出现无法的问题。
  4. 淘宝自己的前端框架KISSY(类似jquery) - 简易指南
  5. 【最大流,二分图匹配】【hdu2063】【过山车】
  6. 考试easy该,学习如何做?
  7. NHibernate查询示例合集
  8. ABAP中的枚举对象
  9. 用SDL库播放yuy2 Packed mode
  10. ceph集群搭建
  11. 获取数值型数组中大于60的元素个数,给数值型数组中不足60分的加20分。(数组,for循环,if条件判断语句)
  12. SpringSecurity个性化用户认证流程
  13. 谈谈我们对userAgent的看法,为什么爬虫中需要userAgent?
  14. Jmeter安装与配置
  15. Codeforces Round #525 (Div. 2)-A/B/C/E
  16. 发邮件、排序、FIFO
  17. 在 Ubuntu 14.04 Chrome中安装Flash Player(转)
  18. linux 信号处理 三 (信号集的使用)
  19. linux 下 nginx的负载均衡
  20. react分享

热门文章

  1. ZSTU OJ 4272 最佳淘汰算法
  2. 洛谷P2713 罗马游戏
  3. TarjanLCA学习笔记
  4. 子查询在INSERT语句中的应用
  5. CodeForces - 524F And Yet Another Bracket Sequence
  6. [CODE FESTIVAL 2016]Encyclopedia of Permutations
  7. mysql数据操作
  8. Maven打war包时,添加本地jar包
  9. Linux下KVM虚拟机基本管理及常用命令(转)
  10. Learning Note: SQL Server VS Oracle–Database architecture