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.

zxcat
  • 2,054
  • 3
  • 26
  • 40
  • 1
    I feel this is due to the new iOS7 full screen layout design. Please refer my answer in http://stackoverflow.com/questions/17074365/status-bar-and-navigation-bar-appear-over-my-views-bounds-in-ios-7/18785646#18785646. That will be helpful... – Nandha Sep 16 '13 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. – zxcat Sep 16 '13 at 17:07

2 Answers2

4

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

self.textContainerInset = UIEdgeInsetsMake(0.0f, 0.0f, -20.0f, 0.0f);
SerTony
  • 41
  • 2
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];
housecube
  • 19
  • 1
  • 1