UITextView text content doesn't start from the top 参考:https://stackoverflow.com/questions/26835944/uitextview-text-content-doesnt-start-from-the-top 我使用的是这种方法: override func viewWillAppear(_ animated: Bool) { yourT
UITextView text content doesn't start from the top
参考:https://stackoverflow.com/questions/26835944/uitextview-text-content-doesnt-start-from-the-top
我使用的是这种方法:
yourTextView.isScrollEnabled = false
yourTextView.text = "....."
}
override func viewDidAppear(_ animated: Bool) {
yourTextView.isScrollEnabled = true
}
原理:当插入大量文本,会导致页面scroll向下,所以在viewWillAppear阶段先锁定页面的scroll,然后导入文本,使其不自动向下scroll。然后在viewDidAppear阶段,再允许scroll