UITextView automatically scrolls upwards when dragging selection handles and textContainerInset is about half the textview height

Anyone else noticed this issue? Is there a workaround? The issue can be reproduced on an iPad Pro 11" with this code:


class ViewController: UIViewController {
   
    @IBOutlet weak var textView: TextView!
   
    override func viewDidLoad() {
        super.viewDidLoad()
        let h = CGFloat(560)
        textView.textContainerInset = UIEdgeInsets(top: h, left: 0, bottom: 0, right: 0)
    }
   
}

Did you ever find an answer to this? I am having the same issue

No, I even filed FB7542868 in January 2020 but never got a response.

I ran into this issue as well, filed a feedback as well and linked yours.

When dignosing the issue to find a fix for this, I doug a bit in the UIKit code. Turns out, UITextView has a (private) method -(BOOL)startAutoscroll:(CGPoint)point which basically takes the input and calculates whether the view should scroll while selecting text.

This method uses both contentInset and textContainerInset to inset the visible rect of the text view. To me this looks like a bug, as textContainerInset should not affect the viewport in a way that contentInset does.

While this issue is extremely annoying, I have no hope that it will ever be fixed. More than 5.5 years have passed since I filed my bug.

UITextView automatically scrolls upwards when dragging selection handles and textContainerInset is about half the textview height
 
 
Q