美文网首页SO 问题来了
textView 《笔记篇》

textView 《笔记篇》

作者: 失忆的程序员 | 来源:发表于2016-07-28 10:13 被阅读6次

1. 代理

2.初始化事件

。。。

// textViewDidChange 每一次输入

- (void)textViewDidChange:(UITextView *)textView {

         // 输入文字上限

          if (textView.text.length >= 160) {

                  XPFLog(@"123123");

           }

         // 当前所有内容 textView.text

          XPFLog(@"textViewDidChange:%@", textView.text);

}


没详细判断字节

NSInteger number = [textView.text length];

if (number > 160) {

UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"字符个数不能大于80"  preferredStyle:UIAlertControllerStyleAlert];

UIAlertAction * action = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault  handler:nil];

[alert addAction:action];

[self presentViewController:alert animated:YES completion:nil];

textView.text = [textView.text substringToIndex:160];

number = 160;

}

XPFLog(@"textViewDidChange:%@", textView.text);


textView 《笔记篇》

相关文章

网友评论

    本文标题:textView 《笔记篇》

    本文链接:https://www.haomeiwen.com/subject/hulajttx.html