开发者

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

开发者 https://www.devze.com 2023-02-08 08:50 出处:网络
I have a UIScrollView which has a subview UITextView. When I added text to UITextView by code, the view is开发者_StackOverflow社区 scrolling to the last line. I want the view not to scroll when I add

I have a UIScrollView which has a subview UITextView. When I added text to UITextView by code, the view is开发者_StackOverflow社区 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?


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];

:)

0

精彩评论

暂无评论...
验证码 换一张
取 消