3

I have an autoscroll feature in my app. When it's activated, my code disables textView scroll and changes contentOffset using CADisplayLink.

Works fine in earlier versions of iOS, but in 7th text appears cropped.

While discovered further I've found that contentSize being changed some time after I disable scroll of textView. Looks like it some kind of optimization. But it don't take contentOffset into account.

To reproduce this bug:

  1. Make sure text in textView is large enough, at least two pages in size.
  2. In ViewController put _textView.scrollEnabled = NO; into -viewDidLoad
  3. In ViewController add:

    - (void)viewDidAppear:(BOOL)animated {
        [super viewDidAppear:animated];
        [_textView setContentOffset:CGPointMake(0, 400) animated:YES];
    }
    

The question is: how to autoscroll UITextView in iOS7 while scrollEnabled set to NO?

Scroll is disabled to stop possible UITextView built-in autoscroll on caret position change and to disallow user interaction with control.

2
  • 1
    I feel this is due to the new iOS7 full screen layout design. Please refer my answer in stackoverflow.com/questions/17074365/…. That will be helpful... Commented Sep 16, 2013 at 11:52
  • 1
    @Nandha, thanks for your comment. Yes, I know about that new UIViewController properties, and checked them too. But result is the same. Commented Sep 16, 2013 at 17:07

2 Answers 2

4

If your text is cropped in the bottom while scrollEnabled is NO:

self.textContainerInset = UIEdgeInsetsMake(0.0f, 0.0f, -20.0f, 0.0f);
Sign up to request clarification or add additional context in comments.

1 Comment

This is the right answer. The other answer doesn't preserve margins in all cases.
1

Doesn't exactly solve the issue, but as a work around, you can allowing scrolling to be enabled, but set UserInteractionEnabled to NO.

[_textView setScrollEnabled:YES];
[_textView setUserInteractionEnabled:NO];

2 Comments

now that is what i was looking for...5 stars for you brother
except now you can't type into it

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.