如何使UITableview转到重新加载页面的顶部? [英] How to get a UITableview to go to the top of page on reload?
本文介绍了如何使UITableview转到重新加载页面的顶部?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我从
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
// A bunch of code...
[TableView reloadData];
}
沿着这些相同的行,我也想去
Along those same lines, I would also like to be able to go to a specific section when I reload the table data.
我尝试放置以下内容,该内容似乎仅适用于重载前后的行,但没有任何反应:
I tried placing the following, which seems applicable only to the row, before and after the reload, but nothing happens:
[TableView scrollToRowAtIndexPath:0 atScrollPosition:UITableViewScrollPositionTop animated:YES];
推荐答案
这是另一种方法:
Objective-C
[tableView setContentOffset:CGPointZero animated:YES];
Swift 3及更高版本
tableView.setContentOffset(.zero, animated: true)
可能是最简单,最直接的方法。
Probably the easiest and most straight forward way to do it.
这篇关于如何使UITableview转到重新加载页面的顶部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文