Ios 将滚动视图重置为顶部

Ios 将滚动视图重置为顶部,ios,uiscrollview,Ios,Uiscrollview,我知道这个问题有点老了,但我解决不了这个问题。需要帮助。 我有一个UIScrollView,每当我上传照片时,我都想将该视图重置为顶部,但我失败了 我已经试过这个代码了 - (void)viewWillAppear:(BOOL)animated; { [super viewWillAppear:animated]; // [[self newSnapView] scrollRectToVisible:CGRectMake(0, 0, 1, 1) animated:NO]; // [[se

我知道这个问题有点老了,但我解决不了这个问题。需要帮助。 我有一个UIScrollView,每当我上传照片时,我都想将该视图重置为顶部,但我失败了

我已经试过这个代码了

- (void)viewWillAppear:(BOOL)animated; {

  [super viewWillAppear:animated];
//  [[self newSnapView] scrollRectToVisible:CGRectMake(0, 0, 1, 1) animated:NO];
// [[self newSnapView] setContentOffset:CGPointMake(0, 0)];
// [[self newSanpView] setContentOffset:CGPointZero animated:YES]];
}
它不会自动弹出到开头,我不知道为什么

[self.newSnapView setContentOffset:CGPointMake(self.scrollView.contentOffset.x, (-1) * self.scrollView.contentInset.top) animated:YES];

应该有用

。。。你说的开始是什么意思?它是否也需要一直向左移动?它不会向上移动到您上载的照片,但会向上移动到某个位置。
(-1)*self.scrollView.contentInset.top
?@LordZsolt这样,即使指定了内容插入,内容也始终位于滚动视图的顶部。该代码补偿了插入的顶部内容。