IOS development-View Controller paging and iospaging
When learning the Open Source Chinese ios source code, we found that the method for implementing view controllers paging is as follows:
1. Define a view controller of the container class, which is similar to UIPageViewController. The vc consists of two parts:
A title view is used to indicate what the current content is, and the user can click to switch the content
B. A table view controller (added through addChildViewController and added the view of table view controller to the view of the container) is used to display the content, that is, paging is implemented in response to user gestures.
Second, set tableview transform, rotate tableview 90 degrees, set pagingEnable to yes (UIScrollView attribute), and set the cell height to the screen width in the table view delegate method, in this way, the table view can be converted into a view that can be paging.
So how to add the view controllers content to the table view? First, add all view controllers to table view controller, and then add the view of view controller to the content view of table view cell, in this way, the content in table view cell is the content of view controllers.
This implementation mainly involves three roles:
1. view controller of the container class, mainly used to coordinate title view and table view controller
2. table view controller, used to implement paging in the horizontal direction of content
3. view controllers, used to provide content
Because UIKit itself provides paging view controller, why not use it directly?
After testing, you can use paging view controller to implement the above basic functions.
Code: https://github.com/beddup/BeddupPageViewControllerDemo