I'm experiencing an issue in my iOS app where tapping to select text in a UITextView that is embedded within a UIScrollView causes the scroll view to jump to an incorrect position. This problem seems to occur only on iOS 15. Does anyone know how to fix this issue, or is there a known bug regarding this behavior on iOS 15?
class ViewController: UIViewController, UITextViewDelegate, UIGestureRecognizerDelegate {
@IBOutlet weak var textView: UITextView!
@IBOutlet weak var scrollView: UIScrollView!
override func viewDidLoad() {
super.viewDidLoad()
textView.isScrollEnabled = false
textView.layoutManager.allowsNonContiguousLayout = false
}
}
Why do you disable the scroll of the textView ?
textView.isScrollEnabled = false
But it is not a very good idea to embed a TextView (scrollView) inside a ScrollView: touch events may mix up, as explained here: https://stackoverflow.com/questions/27652334/uitextview-inside-uiscrollview-with-autolayout