Question

I have a TextView made in the Interface Builder;

It scrolls fine with its default text, but as soon as I programatically set the text to something else, it no longer scrolls.

I do not disable scrolling, and I have tried enabling scrolling (setScrollEnabled:YES), and user interaction (setUserInteractionEnabled:YES) both of which make no difference.

The things that I have found:

  • It scrolls with the default text showing

  • It doesn't seem to matter what text I set in it, it just stops scrolling as soon as it is set. I'm doing it programatically like this:

self.myTextView.text = @"any text"; (or [self.myTextView setText:@"any text"]; has the same effect.)

  • I have two other Textfield in the same View, one of which is using the View Controller as its delegate. The TextField in question is not using the View Controller as its delegate. None of the delegate methods set anything to do with scrolling.

  • Both of the other TextViews have their scrolling capability set to defaults. If I change the one that doesn't need it to no scrolling, it makes no difference to the problem.

  • The one that has the View Controller as its delegate continues to scroll after I edit it (non programatically) and this one continues to be able to scroll once the one in question freezes.

If I delete these two other TextFields, then the one in question works as expected, i.e. it scrolls after adding text.

Any thoughts? Thanks.

Was it helpful?

Solution

Make sure your new text is long enough to be able to get scroll. if text is just one line it wont scroll but if its larger then text area size then it will scroll its by default settings

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top