为什么自动调整 UITextview 在这种情况下不起作用?

Why autosize UITextview is not working in this case?

自动增加 UITextview 不工作,在这种情况下,请帮助我。

这是我增加Textview的代码:

func textViewDidChange(_ textView: UITextView) {
     constTextview.constant = textView.contentSize.height
}

constTextview is Height Outlet for Textview height.

害虫 3 行后 Textview 内滚动不工作。请检查GIF。

这个解决方案适用于我的情况:

constTextview is Height constraint of my Textview.

@IBOutlet var constTextview: NSLayoutConstraint!

func textViewDidChange(_ textView: UITextView) {
     constTextview.constant = textView.contentSize.height
     textView.beginFloatingCursor(at: CGPoint.zero)
     textView.endFloatingCursor()
}