问题描述
如何让 UIScrollView 滚动到顶部?
How do I make a UIScrollView scroll to the top?
推荐答案
iOS 7 更新
[self.scrollView setContentOffset: CGPointMake(0, -self.scrollView.contentInset.top) animated:YES];
原创
[self.scrollView setContentOffset:CGPointZero animated:YES];
或者如果你想保留水平滚动位置并重置垂直位置:
or if you want to preserve the horizontal scroll position and just reset the vertical position:
[self.scrollView setContentOffset:CGPointMake(self.scrollView.contentOffset.x, 0) animated:YES];