How to make a UIScrollView with a UITextView sub v

2019-08-29 05:44发布

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条回答
Bombasti
2楼-- · 2019-08-29 05:55

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

:)

查看更多
登录 后发表回答