UITextField,UITextView字数限制
2013-12-16 13:53
337 查看
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; } }
相关文章推荐
- 更新flash builder4,6 的AIR版本
- sql随机实现,sql GUID
- android UI之去掉状态栏
- mysql起动报错The server quit without updating PID file (/usr/local/mysql/data/
- IOS开发之UINavigationController详解
- IOS开发之UINavigationBar
- ARM汇编实战3: destory stack issue
- TFT ST7735的Netduino驱动
- UIColor 的使用
- 算法:基于 RingBuffer 的 Deque 实现
- ios5 中文键盘高度变高覆盖现有ui问题的解决方案(获取键盘高度的方法)
- Unique Binary Search Trees
- Rebuild index online 引起的ORA-8104错误
- android 子线程不用handler 控制UI线程中的组件
- IOS 表视图UITableView 束NSBundle
- java学习笔记(一)break、continue、ruturn的区别
- quickset切换大小写丢失焦点问题新解决方式
- GUI快捷方式密码不可输
- STL泛型编程-deque双端队列容器
- UICollectionView-事件