适用于tableView与collectionView视图:
1.首先在uiview上添加top_button和tableview视图,代码如下:
[uiview addSubview:tableview];[uiview addSubview:top_button];
[uiview bringSubviewToFront];
3.当top_button按钮按下的时候,调用tableview的返回顶部(即第一个section和cell)的函数,即:
[self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:YES];
UICollectionViewScrollPositionTop
或者:[self.tableView setContentOffset:CGPointMake(0, 20) animated:YES];