擴大我試圖擴大UITextView
在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
@dasdom:這當然有一些影響。我將頂部約束優先級設置爲1000,將底部優先級設置爲250.現在,textView上方的子視圖也向上移動。 textView仍然從頂部擴展。也許我在做錯事情上明智的做法。 – Nitish