Programmatically Stop Scrolling in UITableView

by / Monday, 30 September 2013 / Published in Ipad, Iphone

UITableView is a subclass of UIScrollView, which allows users to scroll through the table, although UITableView allows vertical scrolling only. The cells comprising the individual items of the table are UITableView objects; UITableView uses these objects to draw the visible rows of the table. Cells have content—titles and images etc.

Here we are describing how to stop scrolling of a UITableView programatically.First of all we need to take a UITableView inside a view controller or UITableView type controller(whatever you want).Here we are taking a UITableView Controller and showing a list of animals in it.We also have couple of buttons in the header of the controller. Onclick of those button we will stop or resume scrolling in tableview.The button actions are as follows:

To stop scroll:

self.tableView.scrollEnabled = NO;

To resume scroll:

self.tableView.scrollEnabled = YES;

for reference click here