答案 0 :(得分:0)
请尝试以下代码
目标C:
[self.textView scrollRangeToVisible:NSMakeRange(0, 0)];
<强>夫特:强>
self.textView.scrollRangeToVisible(NSMakeRange(0, 0))
Swift 2(替代解决方案)
将此重写方法添加到ViewController
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
textView.setContentOffset(CGPointZero, animated: false)
}
Swift 3(语法编辑)
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
textView.setContentOffset(CGPoint.zero, animated: false)
}