How do I make a UITableView stop scrolling

I don't mean that I want to disable scrolling. I want to be able to programmatically tell the table to immediately stop moving (but then it should still be scrollable after than). Is this possible?


Solution 1:

A UITableView is a subclass of UIScrollView. If you tell it to scroll to its current position, it will stop scrolling so this should work for you:

[tableView setContentOffset:tableView.contentOffset animated:NO];

Solution 2:

Bind your table view to a variable called tableView, then with the following line you can disable the scrolling in Objective-C:

tableView.scrollEnabled = NO;

Swift version:

tableView.isScrollEnabled = false

Set it to YES (true), if you want it to be scrollable again.