ios--UITextView在光标处添加文字
原文转自:http://blog.sina.com.cn/s/blog_621403ef0100tsvw.html
// 获得光标所在的位置
int location = contentTextView.selectedRange.location;
// 将UITextView中的内容进行调整(主要是在光标所在的位置进行字符串截取,再拼接你需要插入的文字即可)
NSString *content = contentTextView.text;
NSString *result = [NSString stringWithFormat:@”%@[姓名变量]%@”,[content substringToIndex:location],[content substringFromIndex:location]];
// 将调整后的字符串添加到UITextView上面
contentTextView.text = result;
还没有评论,来说两句吧...