【发布时间】:2017-07-21 10:00:45
【问题描述】:
我有两个故事板,一个主要的,然后是第二个包含 UIPageViewController 的故事板。在第二个故事板上,退出按钮允许用户返回到主故事板上的主屏幕。
当我尝试返回主屏幕时,页面控制器视图正在堆叠。我试过用:
self.navigationController?.popViewController
连同其他一些释放 UIPageViewController 集的方法。似乎没有任何工作?我该如何解决这个问题?
您可以在下图中看到由 (3) 标记的控制器。
以下是我的一些尝试。在用户通过是/否自定义模式确认后,我正在使用通知调用根控制器上的方法。
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