Search code examples
iosuitableviewuiscrollview

Disable UITableView horizontal scroll


I created a UITableView with a small frame, like (0,0,50,50). I want to disable the horizontal scrolling but keep the vertical scrolling.

I set self.table.bounces = NO, but the tableview can't be vertically scrolled, either. As a result, the animation is not so perfect.

So anyone has tips?

thanks!


Solution

  • change the content size of the tableView, make sure the width of the content size is not greater than the frame size

    self.tableView.contentSize = CGSizeMake(self.tableView.frame.size.width, self.tableView.contentSize.height);