Answer the question
In order to leave comments, you need to log in
How to hide textView while typing Swift 4?
Hello!
There is a table and in one of the custom cells there is a text View, the fact is that when entering any text, the keyboard closes the entire screen and the entered text is simply not visible, how to make the screen automatically scroll down when entering text?
Answer the question
In order to leave comments, you need to log in
The easiest way, I spent more than a week on this solution:
Download the IQKeyboardManagerSwift library.
After:
func textViewDidChange(_ textView: UITextView) {
let size = textView.bounds.size
let newSize = textView.sizeThatFits(CGSize(width: size.width, height: CGFloat.greatestFiniteMagnitude))
if size.height != newSize.height {
UIView.setAnimationsEnabled(false)
tableView?.beginUpdates()
tableView?.endUpdates()
UIView.setAnimationsEnabled(true)
}
}
scrollToRow(at:at:animated:)
put in the desired delegate method UITextView
.
https://developer.apple.com/documentation/uikit/ui...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question