【发布时间】:2016-03-19 20:17:01
【问题描述】:
我正在尝试在textViewDidChange 中扩展UITextView:
- (void)textViewDidChange:(UITextView *)textView
{
int numLines = textView.contentSize.height/textView.font.lineHeight;
if(numLines < 6)
{
CGRect frame = textView.frame;
frame.size.height = textView.contentSize.height;
textView.frame = frame;
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:(int)textView.tag inSection:0];
MessageDetailCell *cell = [tableMessageDetail cellForRowAtIndexPath:indexPath];
cell.txtReplyHeightConstraint.constant = textView.frame.size.height;
[cell updateConstraintsIfNeeded];
[cell setNeedsLayout];
[cell layoutIfNeeded];
}
}
这确实扩展了UITextView,但从顶部开始。我希望它从底部扩展。我在UITextView 的顶部和底部都应用了约束。
【问题讨论】:
-
尝试更改优先级,使顶部约束的优先级高于底部约束。
-
@dasdom :这肯定会产生一些影响。我将顶部约束优先级设置为 1000,底部约束优先级设置为 250。现在 textView 上方的子视图也向上移动。 textView 仍然从顶部扩展。也许我在优先级方面做错了。
标签: ios iphone autolayout uitextview