[英]UITextView not updating frame unless two or more characters are typed on new line
I noticed a strange behaviour with UITextView. 我注意到UITextView有一个奇怪的行为。
I logged it's height in textViewDidChange
, and found that it's height stays the same unless there are two or more characters on a new line. 我在
textViewDidChange
记录了它的高度,发现除非换行上有两个或更多字符,否则它的高度保持不变。 This is giving me some serious issues. 这给了我一些严重的问题。 Anyone knows a fix?
有人知道解决方法吗?
Using [textView sizeThatFits:textView.frame.size]
returns the correct size as soon as a new line is created. 一旦创建新行,使用
[textView sizeThatFits:textView.frame.size]
返回正确的大小。
I am using autolayout and my UITextView
is embedded in a UITableViewCell
我正在使用自动布局,并且
UITextView
嵌入在UITableViewCell
您应该通过最大高度来代替textView.frame.size,例如:
[textView sizeThatFits:CGSizeMake(textView.frame.size.width, MAXFLOAT)]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.