首页 > 其他 > 详细

两种让tableview返回顶部的方法

时间:2016-06-08 15:32:46      阅读:178      评论:0      收藏:0      [点我收藏+]

1、

 [self.tableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:_currentRow inSection:0] animated:YES  scrollPosition:UITableViewScrollPositionMiddle];

 首先使用selectRowAtIndexes: 选择行数,滚动的话tableview的superview时scrollview,scrollview可以滚动到某个position 那么就要计算这个position position = table row height * index,就得到滚动的位置了。

UITableViewCell自动滚动到顶部
 
[tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:YES];
 
2、继承自scrollview的方法

[self.tableView setContentOffset:CGPointMake(0,0) animated:YES];

两种让tableview返回顶部的方法

原文:http://www.cnblogs.com/huaixu/p/5569900.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!