Parth Patel
Parth Patel

Reputation: 919

Why autosize UITextview is not working in this case?

Autosize increase UITextview is not working, in this case, please help me.

enter image description here

This is my code for increase Textview:

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

constTextview is Height Outlet for Textview height.

After pest 3 lines Textview inner scroll is not working. Please check GIF.

Upvotes: 0

Views: 117

Answers (1)

Parth Patel
Parth Patel

Reputation: 919

This solution working in my case:

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()
}

Upvotes: 1

Related Questions