I have a UITableView whose data source and delegate are switched between a couple of custom data source objects when the user touches a segmented control (think \"Top Paid\"
It was my problem when I had a UISwitch as selector for the tables. But with the segmented control I haven't any problem. Maybe you didn't reload the table? This is my piece of working code:
NSIndexPath *exPath = [[subTable indexPathsForVisibleRows] lastObject];
isMatchOn = [whatList selectedSegmentIndex] == 0 ? YES : NO; //table source will make the choice looking at this BOOL
[subTable reloadData]; // here tables actually flip
if (lastPosition) {
[subTable scrollToRowAtIndexPath:lastPosition atScrollPosition:UITableViewScrollPositionBottom animated:NO]; //I scroll to saved index
}
self.lastPosition = exPath; //here I save the current position
Did you try these 2 methods?
They actually apply to the "scrolling" not just the offset of the content.
[self.tableView scrollToRowAtIndexPath:savedIndexPath atScrollPosition:UITableViewScrollPositionTop animated:NO];
OR:
[self.tableView scrollRectToVisible:savedFrame animated:NO];
They should actually effect the scrolling and by extension the acceleration of the table, not just what is visible on screen.
You could wait for the 'decelerating' property to become NO (e.g. by using KVO) and switch after that.
Have you tried using [view setContentOffset: offset animated: YES]
?
This worked nicely for me:
if (self.tableView.isDecelerating) {
NSArray *paths = [self.tableView indexPathsForVisibleRows];
[self.tableView scrollToRowAtIndexPath:[paths objectAtIndex:0] atScrollPosition:UITableViewScrollPositionTop animated:NO];
}
You could try doing
tableView.scrollEnabled = NO;
tableView.scrollEnabled = YES;
This might stop the scroll by disabling it, then allow it again. I haven't tried this specifically, but I've done similar things.