IntrinsicContentSize is working in iOS 15 but not in iOS 13 and 14

483 views Asked by At

I've created a custom TextField because i need a multiline TextField using "invalidateIntrinsicContentSize" to set the size on every change of the text. In iOS 15 it works perfectly, but in iOS 13 and 14 it's not working.

    final private class UIKitTextView: UITextView {
    override var contentSize: CGSize {
        didSet {
            invalidateIntrinsicContentSize()
        }
    }
    
    override public var intrinsicContentSize: CGSize {
        get {
            print("Invalidate size")
            return CGSize(width: contentSize.width, height: contentSize.height)
        }
    }
}

I tried to debug this code, and if i'm using iOS 15, it calls invalidateIntrinsicContentSize, and then it goes inside intrinsicContentSize and set the new size. If i use iOS 13/14, invalidateIntrinsicContentSize is called, but then it doesn't go inside intrinsicContentSize, so the size doesn't change.

Could someone tell me how can i make it work in iOS 13/14?

Thank you for your patience and help!

0

There are 0 answers