Search code examples
iosxamarinuipageviewcontroller

Xamarin iOS UIPageViewController SetViewControllers see page between


I'm creating a project with an UIPageViewController and tabs just above it.

I want to navigate with Tabs, so I know that I can use SetViewControllers(controller, ...) to jump to another tabs.

But if a have 3 controllers (A, B, C) then I jump from A to C, how can I make an animation which also show B before jumping to C ?

Thanks


Solution

  • You can navigate to C after you jumping from A to B in the callback Event_handler of the method SetViewControllers.Refer the following code.

    pageViewController = new UIPageViewController(UIPageViewControllerTransitionStyle.PageCurl, UIPageViewControllerNavigationOrientation.Horizontal,UIPageViewControllerSpineLocation.Max);
    
    //...
    pageViewController.SetViewControllers(new UIViewController[] { B }, UIPageViewControllerNavigationDirection.Forward, true, (bool finished) =>
      {    
          pageViewController.SetViewControllers(new UIViewController[] { C }, UIPageViewControllerNavigationDirection.Forward, true,null);
      });