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