0

I have a UITableView with a segmented UIBarButtonItem on top, which I use to toggle the list's scope. The scope can either be ingredients or recipes, and the scope toggles the list's contents.

I want to preserve the scroll position independently in the two scopes, so that when switching back and forth, the list maintains its position. I achieve this by saving and restoring the tableView.contentOffset value when toggling.

The problem I want to solve is related to scroll momentum: if the user scrolls "fast" and then toggles the scope, the momentum of the scroll is transferred to the other list, meaning that that list resumes the scroll.

How can I cancel the scroll when toggling scope?

Frost
  • 638
  • 5
  • 20
  • Have a look at this question. It's about how to kill a UIScrollView scrolling, but UITableView is just a subclass of UIScrollView so it should work also. http://stackoverflow.com/questions/3410777/how-can-i-programmatically-force-stop-scrolling-in-a-uiscrollview – nebs Jan 18 '13 at 18:49
  • @Nebs, that works, post as an answer and I will accept. I simply went with the `[UIScrollView setContentOffset:animated]` method after toggling the scope. – Frost Jan 20 '13 at 07:50

1 Answers1

0

Have a look at this question. It's about how to kill a UIScrollView scrolling, but UITableView is just a subclass of UIScrollView so it should work also.

Community
  • 1
  • 1
nebs
  • 4,939
  • 9
  • 41
  • 70