【问题标题】:UIPageViewController stacking ViewControllers when segueing to home page跳转到主页时 UIPageViewController 堆叠 ViewControllers
【发布时间】:2017-07-21 10:00:45
【问题描述】:

我有两个故事板,一个主要的,然后是第二个包含 UIPageViewController 的故事板。在第二个故事板上,退出按钮允许用户返回到主故事板上的主屏幕。

当我尝试返回主屏幕时,页面控制器视图正在堆叠。我试过用:

self.navigationController?.popViewController

连同其他一些释放 UIPageViewController 集的方法。似乎没有任何工作?我该如何解决这个问题?

您可以在下图中看到由 (3) 标记的控制器。

Memory Graph Image

以下是我的一些尝试。在用户通过是/否自定义模式确认后,我正在使用通知调用根控制器上的方法。

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)
}

【问题讨论】:

  • 如果您从第一个开始展示第二个故事板,那么关闭当前的UIPageViewController 是否足以返回,请展示您如何展示第二个视图
  • 我正在模态地展示故事板;在这只是一场表演之前。在主故事板主页上,有一个按钮由触发的 segue 绑定,该 segue 指向 UIPageViewController 的第一页。就在你回复之前,我开始认为也许故事板以某种方式涉及然后找到了这个链接:stackoverflow.com/questions/33369171/…Thoughts?
  • 既然您以模态方式展示控制器,我建议stackoverflow.com/a/24669203/6689101
  • 试了很多次,没有骰子。

标签: ios swift uipageviewcontroller unwind-segue


【解决方案1】:

这是我的问题:

  • 在第一个故事板上,我的导航控制器未设置为初始值。

    • 将其设置为初始值后,我从主 SB 链接到第二个 SB
  • 代表变量未设置为弱

  • RxSwift 未正确处理。
    • 一开始我是通过变量作为全局变量进行发布/订阅。当将观察者移动到我的 UIPageViewController 的根目录时,在页面崩溃时,观察者被丢弃,导致 onComplete 回调被触发。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-11
    • 2015-02-06
    • 2021-10-25
    相关资源
    最近更新 更多