UIPageViewController 在转到主页时堆叠 ViewControllers
UIPageViewController stacking ViewControllers when segueing to home page
我有两个情节提要,一个是主情节提要,另一个是第二个情节提要,其中包含一个 UIPageViewController。在第二个故事板上,退出按钮允许用户 return 到主故事板上的主屏幕。
当我尝试返回主屏幕时,页面控制器视图正在堆叠。我尝试使用:
self.navigationController?.popViewController
与其他一些方法一起取消分配 UIPageViewController 集。似乎没有任何效果?我该如何解决这个问题?
您可以在下图中看到标有 (3) 的控制器。
Memory Graph Image
以下是我的一些尝试。在用户通过 yes/no 自定义模式确认后,我正在使用通知调用根控制器上的方法。
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)
}
这是我的问题:
在第一个故事板上,我的导航控制器未设置为初始值。
- 设置为初始后,我从主SB链接到第二个SB
委托变量未设置为弱
- RxSwift 没有被正确处理。
- 我最初是 pub/sub 通过变量作为全局变量。当将观察者移动到我的 UIPageViewController 的根目录时,在页面分解时观察者被处理掉导致 onComplete 回调命中。
我有两个情节提要,一个是主情节提要,另一个是第二个情节提要,其中包含一个 UIPageViewController。在第二个故事板上,退出按钮允许用户 return 到主故事板上的主屏幕。
当我尝试返回主屏幕时,页面控制器视图正在堆叠。我尝试使用:
self.navigationController?.popViewController
与其他一些方法一起取消分配 UIPageViewController 集。似乎没有任何效果?我该如何解决这个问题?
您可以在下图中看到标有 (3) 的控制器。
Memory Graph Image
以下是我的一些尝试。在用户通过 yes/no 自定义模式确认后,我正在使用通知调用根控制器上的方法。
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)
}
这是我的问题:
在第一个故事板上,我的导航控制器未设置为初始值。
- 设置为初始后,我从主SB链接到第二个SB
委托变量未设置为弱
- RxSwift 没有被正确处理。
- 我最初是 pub/sub 通过变量作为全局变量。当将观察者移动到我的 UIPageViewController 的根目录时,在页面分解时观察者被处理掉导致 onComplete 回调命中。