又是我——学得很快。 问题很简单,我有这样的控制 View : [初始]->[未记录]->[注册] 现在注册后我被双重解雇了,这真的很难看! 我不想直接从注册进入初始页面。 我尝试了这段代码,但遗憾的是它关闭了应用程序,没有任何错误。
self.dismiss(animated: true, completion: {
let controllers = self.navigationController?.viewControllers
for vc in controllers! {
if vc is InitialViewController {
_ = self.navigationController?.popToViewController(vc as! InitialViewController, animated: true)
}
}
} )
pushViewController 的工作方式与上面相同,有输出:
2020-01-29 20:30:38.342180+0100 BillyBill[44355:19540995] Can't end BackgroundTask: no background task exists with identifier 10 (0xa), or it may have already been ended. Break in UIApplicationEndBackgroundTaskError() to debug.
最佳答案
只需弹出到 Root View Controller
self.navigationController?.popToRootViewController(animated: true)
关于ios - Swift iOS - 如何正确使用 popToViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59975026/