How to set a UITableView indexPath?
I have a UITableView that switches dataSource depending on user selection. When a new dataSource is loaded a开发者_如何转开发nd the cells drawn, the indexPath remains the same; fr ex if user was looking at cells 100-120 and selects a new dataSource, cells 100-120 of the new source will be displayed. I would like each dataSource to forget previous view information and start at indexPath 0,0.
Use the scrollToRowAtIndexPath method of UITableView:
[tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:NO];
Send YES if you want the scrolling to be visible / animated.
精彩评论