It seems you are set to custom-made implementation, so this might work.
Calling the -setPage:animated: method before the table view -setPage:animated: its children, giving the cell the ability to do the same, or the automatic maneuver will not work if you do not support any state in the cell (perhaps only the page number) and respond to one or more of the following possibilities:
Waiting for the -viewDidLayoutSubviews method of your UITableViewController to -viewDidLayoutSubviews , then call -cellForRowAtIndexPath: to get the cell. Then the cell must have a valid frame.
Override -didMoveToSuperview in a custom UITableViewCell. By the time this is called, the frame must also be valid.
After any of these points, you can check your custom cell state (which should contain the page number that should be displayed) and scroll to the corresponding point. It would probably be advisable to reorganize your method to set the state (an integer property in the cell) and have a separate private method, which is -setPage:animated: and one of the two labels above can cause offset calculation and scrolling.
Recommended Alternative:
You can remove this by inserting a UICollectionView into the contentView cell. Your UIViewController, which currently implements a UITableViewDataSource, can also implement a UICollectionViewDataSource and provide a collection view of its cells.
Assuming your UITableView cells are the width and height of the screen, you can configure the inline collection view mostly horizontally (since UICollectionView is a subclass of UIScrollView).
When setting up the collection view, use UICollectionViewFlowLayout as the layout object and configure it like this:
// Ensure the collection view scrolls horizontally. let flowLayout = UICollectionViewFlowLayout(); flowLayout.scrollDirection = .Horizontal; let collectionView = UICollectionView(frame:tableCellFrame, layout:flowLayout); // These are actually UIScrollView properties. collectionView.pagingEnabled = true; collectionView.bounces = false;
Then you put each page of content in a custom UICollectionViewCell, and the collection view will paginate them for you. This gives an added bonus to provide you with a scrollable scroll API for free.
source share