I am using the iBook like page turn transition (UIPageViewControllerTransitionStylePageCurl) to navigate a couple of UIViewController pages.
Therefore I implemented UIPageViewControllerDataSource delegate functions
- (UIViewController *)pageViewController:
(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController
{
and
- (UIViewController *)pageViewController:
(UIPageViewController *)pageViewController viewControllerBeforeViewController:
(UIViewController *)viewController
These get called correctly when doing the page turn by gesture. So far, so good.
In addition to this default behavior I’d like to add a long press gesture recognizer to both sides of the page as shortcut to move to the very last page or the very first page quickly. I already managed to add the gesture recognizer to the pages but I don’t know how make the page move without the built-in swipe.
How can I trigger the page turn to a specific page (UIViewController) programmatically?
When the user performs the long swipe you can send the desired viewController (first or last page in your case) to the viewControllers argument of the method:
for more details see Graham’s answer at:
Is it possible to Turn page programmatically in UIPageViewController?
If I read you right, your UIViewControllers that are being displayed contain buttons and you’d like them to also be able to call this function.
To call the method programatically from WITHIN the UIViewControllers being displayed, you could make the UIPageViewController a delegate of your UIViewControllers that are being displayed, then call a delegate method when the buttons are pressed.
A bad way to do it would be to send the UIViewControllers a back-pointer (stored as a WEAK property!) to your UIPageViewController and call respondsToSelector: on it.