目前,当我重新加载表中的数据时,它保持在相同的滚动位置:
[self.tableView reloadData];
如何让滚动位置/高度回到顶部/第一个单元格?
最佳答案
您可以使用以下方法滚动到 TableView 中的任何索引路径:
[self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:YES];
因此,对于第一个单元格,您的 indexPath
将是:
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
您可以更改 scrollPosition
和 animated
参数以获得您想要的效果/结果。
关于ios - 重新加载数据后如何转到 UITableView 中的第一个单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24478570/