0
votes

I've searched and searched still cannot figure out how to fix my problem. I have a UIPageviewController as the initial view controller (like Tinder style). I want each viewController child (page) to be embedded within their own UINavigationController, so basically the page view controller will add the UINavigationController as it's child view controller. And I'm using the setViewController method when a user taps a button in it's child view controller's navigation controller to move to the next view controller by getting a reference to the parent pageviewcontroller, as opposed to using the pageviewcontroller datasource. I don't want to use the pageviewcontroller's datasource because I don't want the swiping gesture.

However, when the user taps the button in the child's navigation controller to trigger it's parent pageviewcontroller to set the next controller, which is also a UINavigationController, the animation of doing this makes the whole screen jump up and then down. If I remove the navigation controller and just send the view controller child instead, then it works fine. Does anyone know why embedding a navigation controller inside a pageviewcontroller would cause this issue?

Here's the code used when a user taps the bar button item in the navigation controller's navigation bar:

func pageViewControllerSetNewControllerFoward() { print("page view controller set matches")

    let storyboard = UIStoryboard(name: "Main", bundle: nil)
    let matchesController = storyboard.instantiateViewController(withIdentifier: "matchesNav") as! UINavigationController

    parentPageViewControllerReference.setViewControllers([matchesController], direction: .forward, animated: true, completion: nil)

}
2

2 Answers

0
votes

The likely culprit of this behaviour is the UINavigationControllertrying to set it's own UINavigationBar. Try setting the

self.navigationController?.setNavigationBarHidden(true, animated: false)

in the viewDidLoad() of your UINavigationController

0
votes

This can be solved by setting Automatically Adjust Scroll Views to false for the PageViewController and NavigationViewControllers.

Do so by self.pageViewController.automaticallyAdjustsScrollViewInsets = false or easier still in Interface Builder under attributes>layout>Adjust Scroll View Insets set to false.