I'm using IQKeyboardManager in my project and it works great other than one issue. I have a UITextView where my users enter comments, when the keyboard is shown the text view moves up as it should, the problem is that if the user types multiple lines of text the text view expands downward with each new line of code, which then goes below the keyboard after 2 lines. If I dismiss the keyboard, then call it again it moves the text view up as it should showing the entire (expanded view), but if I keep typing, again the new lines drop behind the keyboard.
I've tried to use scrolling, which can work, but not the user experience I want, and I've looked at a lot of answers that manage the keyboard, but none that address this issue with IQKeyboardManager.
I don't really have any code aside from the implementation of IQKeyboardManager, but that is working fine.
Any ideas on how I can move the view up with each new line in the text view while using IQKeyboardManager?
I dug in the github and found that it's not really an issue, but that they expect devs to know when the uitextview is going to grow. As such they've developed a call to use when appropriate. IQKeyboardManager.shared.reloadLayoutIfNeeded()
My solution is specific to the width of my text field and the number of characters it takes before creating a new line. Not perfect, but this does work seamlessly in my app, so hopefully someone else can use it.
func textViewDidChange(_ textView: UITextView) {
let count = textView.text.count
if count >= 15 || count >= 30 || count >= 45 || count >= 60 || count >= 75 {
IQKeyboardManager.shared.reloadLayoutIfNeeded()
}
}