我的应用程序有一个自动滚动功能。当它被激活时,我的代码会禁用textView滚动并使用CADisplayLink
来更改contentOffset。
在早期版本的iOS中工作正常,但在第7个版本中,文本会出现裁剪。
进一步发现,一段时间后我禁用textView滚动后,contentSize
被更改了。看起来像某种优化。但它不考虑contentOffset
。
要重现此错误:
- Make sure text in textView is large enough, at least two pages in size.
- In ViewController put
_textView.scrollEnabled = NO;
into-viewDidLoad
In ViewController add:
- (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; [_textView setContentOffset:CGPointMake(0, 400) animated:YES]; }
scrollEnabled
设置为NO
的情况下,自动滚动UITextView
?禁用滚动以防止可能出现的
UITextView
内置的光标位置更改时的自动滚动,并且不允许用户与控件进行交互。