将用户重定向到特定 ViewController - Swift 4
Redirect User to Specific ViewController - Swift 4
我正在尝试在删除该地点后将用户重定向到正确的页面。
navigationController?.popToRootViewController(animated: true)
如果我想重定向到根目录,这会起作用。
navigationController?.popViewController(animated: true)
如果我想重定向到上一个,这将起作用
但在我的例子中,我想重定向到一个特定的页面,而不是根页面或前一个页面。
在 iOS 中如何做这样的事情?
你可以试试
for vc in self.navigationController!.viewControllers {
if let myVC = vc as? VCName {
self.navigationController?.popToViewController(myVC, animated: true)
}
}
如果你现在在你的堆栈中的位置你也可以使用
self.navigationController?.popToViewController(self.navigationController!.viewControllers[1], animated: true)
我正在尝试在删除该地点后将用户重定向到正确的页面。
navigationController?.popToRootViewController(animated: true)
如果我想重定向到根目录,这会起作用。
navigationController?.popViewController(animated: true)
如果我想重定向到上一个,这将起作用
但在我的例子中,我想重定向到一个特定的页面,而不是根页面或前一个页面。
在 iOS 中如何做这样的事情?
你可以试试
for vc in self.navigationController!.viewControllers {
if let myVC = vc as? VCName {
self.navigationController?.popToViewController(myVC, animated: true)
}
}
如果你现在在你的堆栈中的位置你也可以使用
self.navigationController?.popToViewController(self.navigationController!.viewControllers[1], animated: true)