将 UITextView 滚动到底部没有动画
Scroll UITextView to bottom without animation
我有以下代码,它使用动画将文本视图滚动到底部。
- (void)scrollTextViewToBottom:(UITextView *)textView {
[_logTextView scrollRangeToVisible:NSMakeRange([_logTextView.text length], 0)];
}
我看过其他一些使用 contentOffset 的示例,但它们可能存在错误?因为它给出了不一致的结果。
也许你可以试试:
- (void)scrollTextViewToBottom:(UITextView *)textView {
[UIView setAnimationsEnabled:NO];
[_logTextView scrollRangeToVisible:NSMakeRange([_logTextView.text length], 0)];
[UIView setAnimationsEnabled:YES];
}
CGPoint bottomOffset = CGPointMake(0, self.scrollView.contentSize.height - self.scrollView.bounds.size.height);
[self.scrollView setContentOffset:bottomOffset animated:NO];
我有以下代码,它使用动画将文本视图滚动到底部。
- (void)scrollTextViewToBottom:(UITextView *)textView {
[_logTextView scrollRangeToVisible:NSMakeRange([_logTextView.text length], 0)];
}
我看过其他一些使用 contentOffset 的示例,但它们可能存在错误?因为它给出了不一致的结果。
也许你可以试试:
- (void)scrollTextViewToBottom:(UITextView *)textView {
[UIView setAnimationsEnabled:NO];
[_logTextView scrollRangeToVisible:NSMakeRange([_logTextView.text length], 0)];
[UIView setAnimationsEnabled:YES];
}
CGPoint bottomOffset = CGPointMake(0, self.scrollView.contentSize.height - self.scrollView.bounds.size.height);
[self.scrollView setContentOffset:bottomOffset animated:NO];