解決方法
textView.layoutManager.allowsNonContiguousLayout = NO;
這句代碼設置了 UITextView 中的 layoutManager(NSLayoutManager) 的是否非連續(xù)布局屬性忧侧,默認是 YES,設置為 NO 后 UITextView 就不會再自己重置滑動了。
代碼示例
UITextView *textView = [UITextView new];
textView.delegate = self;
textView.frame = CGRectMake(0, self.view.bounds.size.height/3, self.view.bounds.size.width, 100);
textView.backgroundColor = [UIColor lightGrayColor];
textView.font = [UIFont systemFontOfSize:20];
textView.text = @"ABC\nD\nD\nD\nD\nD\nD\nD\nEFG";
// textView.layoutManager.allowsNonContiguousLayout = NO;
[self.view addSubview:textView];