0

I have two storyboards, a main then a second storyboard which houses a UIPageViewController. Inside the second storyboard, an exit button allows a user to return to the home screen which is on the main storyboard.

When I attempt to segue back to the home screen, the page controller views are stacking. I have tried to use:

self.navigationController?.popViewController

Along with some other methods to deallocate the UIPageViewController sets. Nothing seems to work? How do I fix this?

You can see in the image below where the controllers are marked by (3).

Memory Graph Image

Below are a few of my attempts. I am using a notification to invoke a method on the root controller after the user confirms via a yes/no custom modal.

func attempt1() {
    self.viewControllerList.forEach {
        index in
        index.removeFromParentViewController()
        index.dismiss(animated: false, completion: nil)
        index.navigationController?.popViewController(animated: false)
    }
   self.performSegue(withIdentifier: "unwindHome", sender: self)
}

func attempt2() {
    self.childViewControllers.forEach {
        c in
        print("CHILD...>", c)
        c.removeFromParentViewController()
        c.dismiss(animated: false, completion: nil)
    }
}

func attempt3() {
    (view.window?.rootViewController as? UIPageViewController)?.dismiss(animated: true, completion: nil)
    self.dismiss(animated: false, completion: {
        self.viewControllerList.forEach {
            i in
            i.navigationController?.popViewController(animated: true)
        }
    })
   self.performSegue(withIdentifier: "unwindHome", sender: self)
}
velaru
  • 76
  • 1
  • 8
  • if you are showing the second storyboard from the first then wouldn't it be enough to dismiss the current `UIPageViewController` to go back please show how you are presenting the second view – zombie Mar 02 '17 at 02:52
  • I am presenting the storyboard modally; before it was simply a show. On the main storyboard homepage, there is a button that is bound by a triggered segue that leads to the first page of the UIPageViewController. Just before you responded, I began to think maybe the storyboards were involved somehow then found this link: http://stackoverflow.com/questions/33369171/can-an-unwind-segue-work-between-two-storyboards-connected-by-a-storyboard-ref Thoughts? – velaru Mar 02 '17 at 03:02
  • since you are presenting the controller modally i would suggest this http://stackoverflow.com/a/24669203/6689101 – zombie Mar 02 '17 at 03:06
  • Tried a good many, no dice. – velaru Mar 02 '17 at 03:34
  • http://stackoverflow.com/a/13106216/6689101 – zombie Mar 02 '17 at 03:41

1 Answers1

0

Here were my issues:

  • On the first storyboard, my nav controller was not set to initial.

    • After setting it to initial, i then linked from the main SB to the second SB
  • Delegates var's were not set to weak

  • RxSwift was not being disposed of properly.
    • I was at first doing pub/sub via Variables as a Global. When moving the observer into the root of my UIPageViewController, upon page breakdown the observers were disposed of causing the onComplete callback to hit.
velaru
  • 76
  • 1
  • 8