(我需要现有的vc而不是推送vc)
我有一个标签栏和一个导航控制器界面
我的第一个标签栏项目vc1和第二个标签栏项目是vc2
推送vc正常,这就是我做的 步骤1-我点击vc1中的一个按钮,通过导航推送将其导航到vc3
接下来,我点击了vc2标签项 然后我点击vc1标签项和 然后我按下vc3的BACK按钮,我得到的是一个正确的应用程序流
backbutton会弹出viewcontroller
fileprivate func presentDetail(at indexPath: IndexPath) {
self.updateCell(at: indexPath)
self.startLoading()
let vc3 = storyboard?.instantiateViewController(withIdentifier: "vc3") as! vc3
// self.navigationController?.setViewControllers([vc,vc1], animated: true)
vc3.modalPresentationStyle = .overCurrentContext
vc3.data = mDataSource.shared.demoData[indexPath.row]
if let navigator = navigationController {
navigator.pushViewController(vc3, animated: true)
}
@IBAction func backBtnTapped(_ sender: Any) {
self.navigationController?.popViewController(animated: true)
// performSegue(withIdentifier: "unwindSegueToVC1", sender: self)
}
如何让当前的VC工作?
let vc = storyboard.instantiateViewController(withIdentifier: "vc3") as! vc3
vc3.modalPresentationStyle = .overCurrentContext
vc3.data = mDataSource.shared.demoData[indexPath.row]
self.present(vc, animated: true, completion: nil)
答案 0 :(得分:0)
您是否尝试删除此行?
vc3.modalPresentationStyle = .overCurrentContext
只有在您要展示视图时才需要此行。
答案 1 :(得分:0)
fileprivate func presentDetail(at indexPath: IndexPath) {
self.updateCell(at: indexPath)
self.startLoading()
let vc3 = storyboard?.instantiateViewController(withIdentifier: "vc3") as! vc3
self.hidesBottomBarWhenPushed = true //Use this line so you can hide tabbar. when you push to vc3 screen
self.navigationController?.pushViewController(vc3, animated: true)
}
@IBAction func backBtnTapped(_ sender: Any) {
self.navigationController?.popViewController(animated: true)
}