avincross avincross - 3 months ago 65
iOS Question

How to keep UITableView contentoffset after calling -reloadData

CGPoint offset = [_table contentOffset];
[_table reloadData];
[_table setContentOffset:offset animated:NO]; //unuseful

// __block UITableView *tableBlock = _table;
// [self performBlock:^(id sender) {
// [tableBlock setContentOffset:offset];
// } afterDelay:2];


I know no delegate method that is called after
reloadData
.
And
afterDelay:2
may be too short or too long, so how can i implement it?

My English is not good, i hope you can understand...

Answer

I was recently working with reloadData -- reloadData doesn't change the contentOffset or scroll the table view. It actually stays the same if the offset is less than the new amount of data.