Swift Segue 不添加/创建堆栈

Swift Segue Without adding / Creating stack

我想转到我在故事板中创建的视图控制器,而不是将它放在堆栈上。我已经在视图内部有一个导航栏,所以我不想添加另一个。所以基本上我继续的这个新视图将是主视图,所以它是堆栈中唯一的视图。

按钮操作

@IBAction func addToPlanner(_ sender: Any) {
        let objSecondVc = self.storyboard?.instantiateViewController(withIdentifier: "AddToPlannerViewController") as? AddToPlannerViewController
        present(objSecondVc!, animated: true, completion: nil)
}

如果您的 VC 已经有 Navigation Controller 使用 pushViewController

let vc = self.storyboard?.instantiateViewController(withIdentifier: "AddToPlannerViewController") as? AddToPlannerViewController
self.navigationController?.pushViewController(vc!, animated: true)

在 if Button Action 中删除顶部 space 区域 do

let objSecondVc = self.storyboard?.instantiateViewController(withIdentifier: "AddToPlannerViewController") as? AddToPlannerViewController
objSecondVc!.modalPresentationStyle = .fullScreen
present(objSecondVc!, animated: true, completion: nil)