How to make a UIScrollView with a UITextView sub view not scroll when adding text?

百般思念 提交于 2019-12-25 04:33:31

问题


I have a UIScrollView which has a subview UITextView. When I added text to UITextView by code, the view is scrolling to the last line. I want the view not to scroll when I add text to UITextView by code. Anyone can help me fix the problem?


回答1:


Finally I can fix my problem.

We just set YES the setScrollEnabled in UITextView before we change the text in UITextView and set NO after we change the text.

Here the example code

[yourTextView setScrollEnabled:YES];
yourTextView.text = [someString copy];
[yourTextView setScrollEnabled:NO];

:)



来源:https://stackoverflow.com/questions/4861404/how-to-make-a-uiscrollview-with-a-uitextview-sub-view-not-scroll-when-adding-tex

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!