我的后退按钮出现了奇怪的问题。我有2个VC。每个 VC 都有自己的后退按钮(它们不是默认的,它们被添加为左栏按钮项目。当我从 VC1(与主视图 Controller 链接,未显示)到 VC2 时,我看到 VC2,但当我回来时到 VC1 我看到 VC1 的导航栏和 VC2 的 View ,我需要做什么? 我也尝试添加 func 但没有帮助。
override func prepare(for segue: UIStoryboardSegue, sender: Any?) { if segue.identifier == "comeBack" {
let backVC = self.storyboard?.instantiateViewController(withIdentifier: "CollectionVC") as! RecipeCollectionViewController
self.navigationController?.pushViewController(backVC, animated: true)
}
}
最佳答案
用它来将 VC1 推送到 VC2
let vc = self.storyboard?.instantiateViewControllerWithIdentifier("VC2") as! VC2
self.navigationController?.pushViewController(vc, animated: true)
并使用它从 VC2 返回到 VC1
self.navigationController?.popViewControllerAnimated(true)
关于ios - 返回按钮有问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42670289/