-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
I discovered an issue with adjusting the form ScrollView contentInset and contentOffset when the user edits text in a TextAreaRow. This becomes a problem as soon as the form is presented as an page sheet on iOS 13. It looks like the scrolling does not consider the additional top space added by the new page sheet presentation style.
This only happens when the view is displayed with the page sheet style (space at the top).
Also the behavior is not consistent as you can see in this clip:
The same code on iOS 12 without the page sheet presentation style: Also not consistent but does not scroll badly so the first line is invisible:
I guess this is the code that needs some update to fix this:
Lines 1009 to 1037 in 2924259
| @objc open func keyboardWillShow(_ notification: Notification) { | |
| guard let table = tableView, let cell = table.findFirstResponder()?.formCell() else { return } | |
| let keyBoardInfo = notification.userInfo! | |
| let endFrame = keyBoardInfo[UIResponder.keyboardFrameEndUserInfoKey] as! NSValue | |
| let keyBoardFrame = table.window!.convert(endFrame.cgRectValue, to: table.superview) | |
| let newBottomInset = table.frame.origin.y + table.frame.size.height - keyBoardFrame.origin.y + rowKeyboardSpacing | |
| var tableInsets = table.contentInset | |
| var scrollIndicatorInsets = table.scrollIndicatorInsets | |
| oldBottomInset = oldBottomInset ?? tableInsets.bottom | |
| if newBottomInset > oldBottomInset! { | |
| tableInsets.bottom = newBottomInset | |
| scrollIndicatorInsets.bottom = tableInsets.bottom | |
| UIView.beginAnimations(nil, context: nil) | |
| UIView.setAnimationDuration((keyBoardInfo[UIResponder.keyboardAnimationDurationUserInfoKey] as! Double)) | |
| UIView.setAnimationCurve(UIView.AnimationCurve(rawValue: (keyBoardInfo[UIResponder.keyboardAnimationCurveUserInfoKey] as! Int))!) | |
| table.contentInset = tableInsets | |
| table.scrollIndicatorInsets = scrollIndicatorInsets | |
| if let selectedRow = table.indexPath(for: cell) { | |
| if ProcessInfo.processInfo.operatingSystemVersion.majorVersion == 11 { | |
| let rect = table.rectForRow(at: selectedRow) | |
| table.scrollRectToVisible(rect, animated: animateScroll) | |
| } else { | |
| table.scrollToRow(at: selectedRow, at: .none, animated: animateScroll) | |
| } | |
| } | |
| UIView.commitAnimations() | |
| } | |
| } |
I tried to figure it out myself, but could not find a solution yet.
Environment: Eureka 5.1.0, Xcode 11.3


