1、tableView一行代码滚动到顶部
[self.tableView scrollRectToVisible:CGRectMake(0, 0, 1, 1) animated:YES];
tableView一行代码滚动对应cell
//获取到需要跳转位置的行数
NSIndexPath *scrollIndexPath = [NSIndexPath indexPathForRow:10 inSection:0];
//滚动到其相应的位置
[[self tableView] scrollToRowAtIndexPath:scrollIndexPath
atScrollPosition:UITableViewScrollPositionTop animated:YES];
枚举类型
以下枚举决定滚动到指定位置的哪个位置
typedef NS_ENUM(NSInteger, UITableViewScrollPosition) {
UITableViewScrollPositionNone,
UITableViewScrollPositionTop,
UITableViewScrollPositionMiddle,
UITableViewScrollPositionBottom
};
2、scrollView一行代码滚动到顶部
[self.scrollView setContentOffset:CGPointMake(0,0) animated:YES];
https://www.jianshu.com/p/8f6b8b2be986
https://www.cnblogs.com/hero11223/p/9237205.html
网友评论