2011-12-27 48 views

回答

87

使用下面的代码:

scrollView.contentOffset = CGPointMake(0,0); 
+1

scrollView.contentOffset = CGPointMake(0,0); – user1072740 2011-12-27 13:02:40

+27

如果您需要动画,请使用[scrollView setContentOffset:CGPointMake(0,0)animated:YES]。 – acoustic 2013-10-20 12:39:45

43

为了动画的滚动做到这一点:

CGRect frame = CGRectMake(0, 768, 1024, 748); //wherever you want to scroll 
[self.scrollView scrollRectToVisible:frame animated:YES]; 
+0

有没有办法让你不必指定滚动视图的宽度和高度? – Nirri 2016-05-14 13:59:17

0

雨燕3.0版本的答案是:

scrollView.contentOffset = CGPoint(x: 0.0, y: 0.0)

2

最简单的方法with animation - >

[scrollView setContentOffset:CGPointMake(0, 0) animated:YES] 
相关问题