I've a table view below which I've text view. I scroll table view up with text view's height increases. The problem is that table view doesn't scroll up when return key is hit and cursor goes to new line, instead it scrolls up when a character is typed in this new line.
How do I fix so that table view scrolls up as soon as return key is pressed?
The pointed duplicate post is donkey ages old and solution is not in swift so that doesn't answer my question.
func textViewDidChange(_ textView: UITextView) {
let estimatedSize = textView.sizeThatFits(textView.frame.size)
if estimatedSize.height >= self.textViewMaxHeight {
textView.isScrollEnabled = true
textView.showsVerticalScrollIndicator = true
let bottomOffset = CGPoint(x: textView.contentOffset.x, y: textView.contentSize.height - textView.bounds.size.height)
textView.setContentOffset(bottomOffset, animated: false)
} else {
textView.isScrollEnabled = false
}
if self.dataSource.count > 0 {
if tableView.contentOffset.y < (tableView.contentSize.height - tableView.frame.size.height) {
self.tableView.scrollToBottom()
}
}
}