UITableView回到顶部
//***************方法一***************//
//1.UITableView自带方法滚动到某组某行:
[self.tableView scrollRectToVisible:CGRectMake(0, 0, 1, 1) animated:NO];
//注意:可能会有数组越界奔溃的情况(如有有section但没有cell的情况),不能保证的情况下不要使用。
//***************方法二***************//
//2.UITableView继承UIScrollView,可以调用UIScrollView滚动到设定区域的的方法
[self.tableView setContentOffset:CGPointMake(0,0) animated:NO];
//***************方法三***************//
//3.设置偏移量
NSIndexPath* indexPat = [NSIndexPath indexPathForRow:0 inSection:0];
[self.tableView scrollToRowAtIndexPath:indexPat atScrollPosition:UITableViewScrollPositionBottom animated:YES];
本文标题:UITableView回到顶部
本文链接:https://www.haomeiwen.com/subject/hygwgctx.html
网友评论