简体   繁体   中英

UIPageViewController transitioning to another view on event

I have a UIPageViewController with 3 views. I want to change from one view to another on a button event (something like snapchat buttons that help you through navigation, even though swipes also do the job). I'm currently using the following:

//the navWrapper is the view currently displayed
//it asks the PageViewController to set its view abruptly to the nextWrapper
[navWrapper.rootViewController.pageViewController setViewControllers:@[nextWrapper] direction:UIPageViewControllerNavigationDirectionReverse animated:NO completion:nil];

This works because it changes the view controller displayed correctly, but I'm looking a way to have that transition just like a swipe would look like (instead of the harsh change in the view with no animation that is going on right now).

Been looking around but haven't figured this out yet, suggestions are appreciated :)

Why not set animated to YES

[navWrapper.rootViewController.pageViewController setViewControllers:@[nextWrapper] direction:UIPageViewControllerNavigationDirectionReverse animated:YES completion:nil];

and if you are interested there is a way to trigger the gesture recognizer programmatically in this question

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM