简体   繁体   中英

How to customize the UITableView scrolling in horizontal direction?

I have a requirement to show the table view in horizontal scrolling.

Eg: In 1st page have to show 10 rows, while scrolling (Horizontal) to the 2nd page have to show 10 more rows, like that I have to show.

How can it be possible?

Use a UIScrollView and turn on pagingEnabled . Then put a UITableView on each page.

Picked this up from an Apple engineer at WWDC: Try setting the tableview's transform to rotate it 90 degrees. Let's see, I think it'd be something like:

Objective-C

self.tableView.transform = CGAffineTransformMakeRotation(90.0 * M_PI / 180); //Convert 90 degrees to radians

Swift 4+

self.tableView.transform = CGAffineTransform(rotationAngle: 90.0 * .pi / 180) //Convert 90 degrees to radians

You'll get all the easy view recycling of a tableview, just horizontally. If subviews of each cell need to be oriented normally, just apply a corresponding rotation transform on those in a UITableViewCell subclass.

How about implementing UiTableView inside a superior UICollectionView cells? I think there is already a topic for my solution here

What you can do to have scrolling horizontally in table view is. Add scrollers to your table view rows and set contents size with increasing width and fixed height.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM