UITextView文本内容不是从顶部开始 [英] UITextView text content doesn't start from the top
本文介绍了UITextView文本内容不是从顶部开始的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的JSON文件中有一个长文本,但是当我单击UITableViewCell中的链接转到我的UIViewController页面时,UITextView文本会加载字符串内容,但不会从头开始显示内容,因此我必须一直向上滚动.
I have a long text coming from my JSON file but when I click the link from my UITableViewCell to go to my UIViewController page, the UITextView text loads the string content but it does not show the content from the beginning and I have to scroll up all the time.
我需要做什么?
推荐答案
我遇到了同样的问题,结果我不得不在viewDidLayoutSubviews中设置内容偏移才能生效.我正在使用此代码显示归因于静态的文本.
I had the same problem, and turns out I had to set the content offset in viewDidLayoutSubviews for it to take effect. I'm using this code to display attributed static text.
- (void)viewDidLayoutSubviews {
[self.yourTextView setContentOffset:CGPointZero animated:NO];
}
SWIFT 3:
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
self.textView.setContentOffset(CGPoint.zero, animated: false)
}
这篇关于UITextView文本内容不是从顶部开始的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文