对于自定义创建回复框, textView自适应高度, 根据textView.contentSize.height调节高度时, 有时候会有textView换行时文字跳动过高, 不是平滑过渡.
请参考一下代码: [textView scrollRangeToVisible:NSMakeRange(0, 0)]; 能有效避免自适应高度时文字跳动不符的情况.
-(void)textViewDidChange:(UITextView *)textView{
NSInteger wordCount = textView.text.length;
self.textView.countNum = wordCount;
CGFloat height = textView_height;
if (textView.contentSize.height < 150) {
if (textView.contentSize.height > 30) {
height = 85 + textView.contentSize.height;
}else{
height = textView_height;
}
self.textView.y = KScreenHeight - self.keybordHeight - height;
self.textView.h = height;
[textView scrollRangeToVisible:NSMakeRange(0, 0)];
}
}
网友评论