这是XIB文件( ChatInputBar.xib )
我正在根据内容并使用此代码尝试更新textview的高度
- (void)textViewDidChange:(UITextView *)textView{
CGRect frame = textView.frame;
frame.size.height = textView.contentSize.height;
if(frame.size.height > textView.frame.size.height){
CGFloat diff = frame.size.height - textView.frame.size.height;
textView.frame = CGRectMake(textView.frame.origin.x, textView.frame.origin.y - diff, textView.frame.size.width, frame.size.height);
}
else if(frame.size.height < textView.frame.size.height){
CGFloat diff = textView.frame.size.height - frame.size.height;
textView.frame = CGRectMake(textView.frame.origin.x, textView.frame.origin.y + diff, textView.frame.size.width, frame.size.height);
}
}
我得到了这个结果
我怎样才能更新整个视图的高度?