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!
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).
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.
Check if the content inset property of the table view is nonzero. If so reset it to zero.
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);
You can set AlwaysBounceHorizontal
property of UITableView to false as follows:
Swift:
self.tableView.alwaysBounceHorizontal = false
Objective-C:
[self.tableView setAlwaysBounceHorizontal:NO];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With