Open D-Mx opened 5 years ago
I found out that by doing .onChange { self.view.layoutIfNeeded() }
alone automatically scrolls to the caret but not for new lines, is not until I write again that the the table scrolls
Did you try scrolling the row to the .middle
or .top
of the screen?
tableView.scrollToRow(at: indexPath, at: .middle, animated: true)
yes, but with the keyboard showing that doesn't always make the cursor/caret visible if you are at the bottom of a long text
in my cases problem in ios 12, ios 13 no error
.onChange { self.view.layoutIfNeeded() } works for me (new line and caret)
@D-Mx I can confirm this issue. I also see this!
I found a workaround for this.
First, save the keyboard-will-show-notification and the text area row height.
var detailRow: TextAreaRow?
var keyboardWillShowNotification: Notification?
var previousDetailRowHeight: CGFloat = 0
override func keyboardWillShow(_ notification: Notification) {
super.keyboardWillShow(notification)
keyboardWillShowNotification = notification
}
override func keyboardWillHide(_ notification: Notification) {
super.keyboardWillHide(notification)
keyboardWillShowNotification = nil
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
previousDetailRowHeight = detailRow!.cell.textView.frame.size.height
}
Then you can manually call keyboardWillShow
again in the text area row onChange
to scroll the text field to visible when it gets bigger.
.onChange({ [unowned self] (row) in
guard let keyboardWillShowNotification = self.keyboardWillShowNotification else { return }
let rowHeight = row.cell.textView.frame.size.height
if rowHeight > self.previousDetailRowHeight {
// to scroll cell to visible, to prevent keyboard from hiding texts
self.keyboardWillShow(keyboardWillShowNotification)
}
self.previousDetailRowHeight = rowHeight
})
Hello,
I have a problem where in a TextAreaRow if you add a large text the content goes under the keyboard. I want the tableview to show the content like in the Apple Notes App. I'm trying to scroll the tableview on the
onChange
event but not even a hardcoded space scrolls the table.Eureka 5.0.0