解决方式:
1.定义一个textview,在storyboard中设定该textview的constraints。
2.将高度的constraint定义到头文件里:(直接拖拽)
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *textviewHeightConstraint;3.待在实现文件里为textview载入了内容之后,获取文本高度,为该constraint赋值:
CGSize sizeThatShouldFitTheContent = [self.shippingAddressTextView sizeThatFits:self.shippingAddressTextView.frame.size];
self.textviewHeightConstraint.constant = sizeThatShouldFitTheContent.height;參考链接:
http://stackoverflow.com/questions/50467/how-do-i-size-a-uitextview-to-its-content/2487402#2487402
原文:http://www.cnblogs.com/gcczhongduan/p/4009183.html
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!