Daniel Stein
Daniel Stein

Reputation: 41

UITableView scrolls itself

I've a weird problem with a UITableView. At the top of the tableview is a UISearchBar that I hide at viewDidLoad with

self.tableView.contentOffset = CGPointMake( 0, self.searchBar.frame.size.height );

Everything works fine, if the UITableView has enough cells, so that is scrollable. However, if there are only a few cells, sometimes my tableview scrolls itself to the bottom. It happens when I interact with the cells (theres a button on the contentview) or if I load another modal viewcontroller.

I suspect that Autolayout has something to do with it, but I don't really know where I should start looking.

Here are two screenshots to illustrate my problem.

This is the tableview at viewDidLoad.

enter image description here

This is my tableview after the unwanted scrolling occurs:

enter image description here

Upvotes: 1

Views: 333

Answers (1)

Renan Soares
Renan Soares

Reputation: 11

Make sure that your tableview doens't have paging enabled

self.tableView.pagingEnabled = NO

or go to your storyboard and uncheck Paging Enabled on the attributes inspector of your tableView

Upvotes: 1

Related Questions