Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 388
scorpiozj Avatar asked Apr 25 '12 05:04

scorpiozj


People also ask

Can UITableView scroll horizontal?

Using the horizontally scrolling cells of the UITableView enables us to develop a highly intuitive interface. It also enables the user to glance a lot of information (9 titles in the picture above).

How can use horizontal scroll in jquery?

The scrollLeft() method sets or returns the horizontal scrollbar position for the selected elements. Tip: When the scrollbar is on the far left side, the position is 0. When used to return the position: This method returns the horizontal position of the scrollbar for the FIRST matched element.


3 Answers

Check if the content inset property of the table view is nonzero. If so reset it to zero.

like image 172
lazymind Avatar answered Oct 10 '22 01:10

lazymind


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);
like image 27
wattson12 Avatar answered Oct 10 '22 01:10

wattson12


You can set AlwaysBounceHorizontal property of UITableView to false as follows:

Swift:

self.tableView.alwaysBounceHorizontal = false

Objective-C:

[self.tableView setAlwaysBounceHorizontal:NO];
like image 27
Luiz Dias Avatar answered Oct 10 '22 00:10

Luiz Dias