Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
722 views
in Technique[技术] by (71.8m points)

cocoa touch - UITextView automatic scroll down

I have an UIView and I add a editable UITextView to it,

UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(5, 5, 219, 47)];
[self addSubview:textView];
textView.font = [UIFont systemFontOfSize:14];

When I type it doesn't go down automatic. Anybody got an idea?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Just figured out that you must use a length > 0. Ie

NSRange range = NSMakeRange(textView.text.length - 1, 1);
[textView scrollRangeToVisible:range];

Worked for me anyway.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...