我有一个UITableView,根据用户选择切换dataSource。加载新的dataSource并绘制单元格时,indexPath保持不变;如果用户正在查看单元格100-120并选择新的数据源,则将显示新源的单元格100-120。我希望每个dataSource都忘记以前的视图信息,并从indexPath 0,0开始。
答案 0 :(得分:4)
使用UITableView的scrollToRowAtIndexPath方法:
[tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:NO];
如果您希望滚动显示/动画,请发送YES。