我不认为有人可以指导我以正确的方式动态调整 UITextView 的大小,同时仍然使用自动布局?也就是说,使用 Swift。
我已经尝试以编程方式调整底部约束,试图让 UITextView 包含内容。但是我不确定如何获取 UITextView 内容的高度?
我正在尝试将数据加载到 UITextView 字段中,然后动态调整它们以使其看起来整洁。
@IBOutlet weak var serviceDescriptionTextViewBottomGuide: NSLayoutConstraint!
override func viewDidLoad() {
self.activityName.text = serviceCodes[selectionValue]
self.serviceDescriptionTextView.text = serviceDescription[selectionValue]
self.whenToUseDescriptionTextView.text = whenToUseCode[selectionValue]
self.serviceDescriptionTextViewBottomGuide?.constant += x
}
最佳答案
禁用滚动并且不要设置任何其他可以决定 UITextView 高度的约束。
关于swift - 基于 Swift 内容的动态 UITextView 大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29403241/