UITextView实时跟踪输入文字的个数,超过禁止输入并阶段
来源:互联网 发布:花刺代理软件 编辑:程序博客网 时间:2024/06/10 17:14
#pragma mark - UITextViewDelegate- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{ if([text isEqualToString:@"\n"]){ [textView resignFirstResponder]; return NO; } UITextRange *selectedRange = [textView markedTextRange]; UITextPosition *position = [textView positionFromPosition:selectedRange.start offset:0]; if(position && (range.length==0 || text.length==0)){ return YES; }else{ NSString *str = [textView.text stringByReplacingCharactersInRange:NSMakeRange(range.location, range.length) withString:text]; if(str.length>40){ self.remarkTextView.text = [str substringToIndex:40]; [self.dict setObject:self.remarkTextView.text forKey:@"remark"]; if(self.ticketParamEdit){ self.ticketParamEdit(self.dict, self); } return NO; }else{ [self.dict setObject:str forKey:@"remark"]; if(self.ticketParamEdit){ self.ticketParamEdit(self.dict, self); } } } return YES;}
阅读全文
0 0
- UITextView实时跟踪输入文字的个数,超过禁止输入并阶段
- UITextField实时跟踪输入文字的个数,超过禁止输入并阶段(UITextView也可以使用类似方法)
- js实时统计文本框中输入文字的个数
- UITextView输入属性文字
- iOS:如何优雅的让UITextView根据输入文字实时改变高度
- iOS:如何优雅的让UITextView根据输入文字实时改变高度
- 文字输入的实时对比
- UITextView设置输入个数限制
- UITextView输入文字长度限制
- iOS8 UITextView 输入内容实时更新 cell 的高度
- iOS UITextView 输入内容实时更新cell的高度
- iOS UITextView 输入内容实时更新 Cell 的高度
- iOS UITextView 输入内容实时更新cell的高度
- iOS UITextView 输入内容实时更新cell的高度
- iOS UITextView 输入内容实时更新cell的高度
- iOS UITextView 输入内容实时更新cell的高度
- iOS UITextView 输入内容实时更新 cell 的高度
- UITextField实时打印输入的文字
- jQuery对复选框(checkbox)的全选,全不选,反选等的操作
- 如何寻找数组中的最大值和最小值
- 如何将 iOS 项目的编译速度提高5倍
- LeetCode
- 封装,继承,多态
- UITextView实时跟踪输入文字的个数,超过禁止输入并阶段
- linux内存管理slab算法之slab初始化
- 杭电ACM题目分类大全
- 功能展示——ExpandableListView中嵌套GridView
- 递归删除文件夹
- 浅析《新一代人工智能发展规划》【智库2861】
- iOS音频播放 (八):NowPlayingCenter和RemoteControl
- JDBC中的Statement和PreparedStatement的区别
- python操作mysql数据库