In iOS how do you make a UITextView scrollable and responsive to touch when there's little or no content?
In my app, once text fills up the textview, scrollbars appears and I can scroll around. Less than that though, and since all the content is withen the frame of the UITextView, it's static and doesn't move.
What I want would work like the iPhone Notes application, whether there's one line of text or even when a note is empty, you can scroll the view.
Right now I'm only using a UITextView, and I'm having a hard time understanding whether a UIScrollView is also needed.
I wasn't able to find a question specific to this issue. Thanks!
For anyone that stumbles upon this page in the future:
I was able to achieve this by simply enabling alwaysBounceVertical
, and making sure User interaction and scrolling was enabled.
self.textView.scrollEnabled = YES;
self.textView.userInteractionEnabled = YES;
self.textView.alwaysBounceVertical = YES;
For Swift 3.0:
textView.alwaysBounceVertical = true
textView.isUserInteractionEnabled = true
textView.isScrollEnabled = true
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