iOS 8中UITextView内容大小未增加
我创建了一个UITextView,并将iOS 8中UITextView内容大小未增加,ios,swift,ios8,uitextview,Ios,Swift,Ios8,Uitextview,我创建了一个UITextView,并将IsCrollenabled设置为true,在我将两行文本粘贴到textView后,我通过键盘输入文本,但textView的contentSize没有增加,它只发生在iOS 8中,并且仅在我粘贴两行文本后 func textViewDidChange(_ textView: UITextView) { if textView.text.isEmpty { updateCommentViewHeight(45.0) } else
IsCrollenabled
设置为true,在我将两行文本粘贴到textView后,我通过键盘输入文本,但textView的contentSize
没有增加,它只发生在iOS 8中,并且仅在我粘贴两行文本后
func textViewDidChange(_ textView: UITextView) {
if textView.text.isEmpty {
updateCommentViewHeight(45.0)
} else {
let height = calculateTextSize(with: textView).height //calulate textview height by content text
updateCommentViewHeight(height + 30.0)
if commentInputView.bounds.height > height + 29.0 {
textView.isScrollEnabled = true
} else {
textView.isScrollEnabled = false
}
}
}
private func updateCommentViewHeight(_ height: CGFloat) {
constrain(commentInputView, replace: group, block: { (commentInputView) in
commentInputView.height == height
})
view.layoutIfNeeded()
}
@lamOwenHong,请为
commentInputView
等发布更多代码。@aircraft commentInputView是一个自定义UIView,它包含一个UITextView,UITextView的约束偏移量为commentInputView的10px。我的意思是您应该发布更多代码或情节提要图像屏幕,例如updateCommentViewHeight
方法代码,所以我们可以方便地测试它。@aircraft,谢谢,我只是更新了question@lamOwenHong,请为commentInputView
等发布更多代码。@aircraft commentInputView是一个自定义UIView,它包含一个UITextView,UITextView的约束偏移量为commentInputView的10px。我的意思是你应该发布更多的代码或故事板图像屏幕,例如updateCommentViewHeight
method代码,这样我们就可以方便地测试它了。@aircraft,谢谢你,我刚刚更新了问题