Paging horizontally between two table views in Swift

894 views Asked by At

I want to have two table views sitting horizontally next to each other. I am able to set up a UIPageControl along with a UIScrollView to page between two images, but how do I set up two UITableViews next to each other within a UIScrollView who's width is of screenWidth*2 to page between the table views?

The tricky part is, once I get this to work, I need to be able to put the resulting construct itself into a UITableViewCell because the whole thing is also part of a bigger encompassing table view.

Would I create two different UITableViewController classes that each load their respective data, and then dynamically load those into UIViews of screenWidth width in the UIScrollView? I'm really lost here as to how to go about this.

1

There are 1 answers

0
Shamas S On BEST ANSWER

Create a UIPageViewController. Create your 2 UITableViewController's and set them as - setViewControllers:direction:animated:completion:. This will automatically handle the swipe between them. You wouldn't need to add them to a UIScrollView.