1

I have a UITextView. The text in the view keeps changing based on user action. On many occasions, the text is too large to fit and so my text view (which has a desired fixed width and height) scrolls the text. The control flow is something like this 1) user takes some action, and text view appears with some text (possibly more than what can fit, so comes with a scroll) 2) user dismisses the view (I simply hide the text view) 3) user takes another action, and text view appears with new text (i use UITextView setText to reassign the text, and simply turn the hidden property to NO)

My text cannot be edited by the user. It is always reset to a different string in code

Problem: When the textview is redrawn/rendered with the new text, on some occassions the contentoffset.y AND bounds.origin.y values of the text view are set to something besides 0, which is not desirable. It is intermittent, but creates a major UI issue. At least I think those new values are what causes the UI to look so weird. Open to other suggestions here...

I want to know why this happens, and how to fix this? Since the text is changed programatically, I can't depend on textViewDidChange: to reset these values.

EDIT: This is how I am changingt he text everytime something new has to be placed in the textview

[textView1 setText:someNSString];

where someNSString is, well, some string with text

XConfusion
  • 345
  • 1
  • 4
  • 13

0 Answers0