我的导航是:
List of Friends with messages Controller
(点击撰写)-> List of friends to select chatting
(选择 friend )-> Show chat with friend
目前,如果在 Show chat with friend
中,用户选择 back
,它会将他们带到 List of friends 以选择聊天
Controller 。
我想跳过这个 Controller ,并在返回选择时导航到 List of Friends with messages Controller
注意:List of Friends with messages Controller
嵌入在选项卡中。
我尝试使用:self.navigationController?.viewControllers.removeLast()
,在选择聊天的 friend 列表
之间的segue
中> 将其从堆栈中移除。但是在导航到 Show chat with friend
之后,后退按钮消失了......
如何允许我描述的导航?
最佳答案
如果您的目标是跳过第二个 UIViewController
并从第三个 UIViewController
返回到第一个 UIViewController
。试试下面的代码:
// This count will return how many view controllers are there in navigation stack
let controllersInNavigationCount = self.navigationController?.viewControllers.count
// This will pop to first UIViewController skipping second UIViewController
self.navigationController?.popToViewController(self.navigationController?.viewControllers[controllersInNavigationCount!-2] as! FirstViewController, animated: true)
关于ios - 如何在按下后退按钮时跳过上一个 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37636393/