UIScrollView以编程方式滚动到底部 [英] UIScrollView scroll to bottom programmatically
本文介绍了UIScrollView以编程方式滚动到底部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在我的代码中滚动到底部 UIScrollView
?或者以更通用的方式,到子视图的任何一点?
How can I make a UIScrollView
scroll to the bottom within my code? Or in a more generic way, to any point of a subview?
推荐答案
您可以使用UIScrollView的 setContentOffset:animated:
用于滚动到内容视图的任何部分的函数。假设你的scrollView是 self.scrollView
:
You can use the UIScrollView's setContentOffset:animated:
function to scroll to any part of the content view. Here's some code that would scroll to the bottom, assuming your scrollView is self.scrollView
:
CGPoint bottomOffset = CGPointMake(0, self.scrollView.contentSize.height - self.scrollView.bounds.size.height);
[self.scrollView setContentOffset:bottomOffset animated:YES];
希望有所帮助!
这篇关于UIScrollView以编程方式滚动到底部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文