My project is an eBook-reader (ePub) with UIPageViewController holding webViews to show the pages.
The pages are computed by loading a webView with a chapterFile and counting the pages the webView needs to display in webViewDidFinishLoad. This will be done for all chapterFiles in a delegate called trough webViewDidFinishLoad, where the next chapter will be loaded in a webView to compute the pages.
On certain conditions, like turning from portrait to landscape with new textSize in portrait, the pageViewController is demanding a second page faster than the paging needs to finish.
PageViewController is calling
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController
In this method I am calling another method "goToNextPage" to look if the next Page is a shift of the webViews viewPort or an new chapterFile to load.
What I want is "goToNextPage" to wait for the paging to be done.
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController{
...
//paging is already in progress at this point (if needed )
//I want goToNextPage to wait for paging to be finished
[self goToNextPage];`
...
//loading newViewController with right page
return newViewController;
}
I don't know how to achieve this because of the delegate calls to wait for.