小编Fil*_*ipe的帖子

Swift 3:popToViewController无法正常工作

在我的应用程序中,我有三个表视图控制器,然后可能有许多UIViewControllers,如果用户在任何时候按下,每个UIViewControllers都必须返回到第一个表视图控制器.我不希望用户必须回溯可能数百页.这是我有趣的,以确定用户是否按下后退按钮,它的工作原理是打印消息

override func viewWillDisappear(_ animated: Bool) {
    if !movingForward {
        print("moving back")
        let startvc = self.storyboard!.instantiateViewController(withIdentifier: "FirstTableViewController")
        _ = self.navigationController!.popToViewController(startvc, animated: true)
    }
}
Run Code Online (Sandbox Code Playgroud)

我已经搜索过,到目前为止还没有解决方案.

uinavigationcontroller ios poptoviewcontroller swift3

3
推荐指数
1
解决办法
4585
查看次数