I have UITextView with disabled scrolling. I need to change maximumNumberOfLines
programmatically and see updates on UI after this. UITextView uses auto layout.
textView.textContainer.maximumNumberOfLines = 0
This should make visible the whole text from the textView on UI.
P.S. Similar questions were asked many times but the answer that works for me I haven't found.
I found out how to achieve it by myself.
So basically when you change textView.textContainer.maximumNumberOfLines
UIKit doesn't know about this (but I think should). Even when you try to update a layout. The solution is simple:
textView.textContainer.maximumNumberOfLines = 0
textView.invalidateIntrinsicContentSize() //add this line
Call this when something changes that affects the intrinsicContentSize to notice UIKit.
I hope it will be useful and save somebody's time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With