ios - 获取 UIScrollView 滚动到顶部

如何让 UIScrollView 滚动到顶部?

最佳答案

iOS 7 更新

[self.scrollView setContentOffset:
    CGPointMake(0, -self.scrollView.contentInset.top) animated:YES];

原创

[self.scrollView setContentOffset:CGPointZero animated:YES];

或者如果您想保留水平滚动位置并重置垂直位置:

[self.scrollView setContentOffset:CGPointMake(self.scrollView.contentOffset.x, 0)
    animated:YES];

https://stackoverflow.com/questions/9450302/

相关文章:

ios - 如何在 UITableViewCell 之间添加间距

ios - UIButton 标题文本颜色

objective-c - 如何判断 UITableView 何时完成 ReloadData?

ios - 在 iOS 6 中以编程方式打开 map 应用

ios - 更改 UIImageView 的图像时淡入淡出/溶解

objective-c - 仅在 iOS 7 上运行时,Storyboard 原型(prototyp

ios - 错误 : _handleNonLaunchSpecificActions in iOS9

objective-c - 从 NSString 中删除除数字之外的所有数字

ios - 带有隐藏 UIView 的自动布局?

ios - Xcode 调试器不打印对象并显示 nil,当它们不是时