swift - 从导航控制器回到视图控制器?
问题描述
我是 Swift 开发的初学者,我被困在某一点上。我有一个 ViewController1(入口点)、导航控制器和 ViewController2。ViewController2 包含XLPagerTabStrip并嵌入在导航控制器中。我可以使用以下代码从 ViewController1 移动到导航控制器。
let navigationController = mainStoryBoard.instantiateViewController(withIdentifier: "NavigationController") as! UINavigationController
let viewController = mainStoryBoard.instantiateViewController(withIdentifier: "ParentViewController") as! ParentViewController
navigationController.pushViewController(viewController, animated: true)
self.present(navigationController, animated: true, completion: nil)
现在的问题是我无法从导航控制器移回 ViewController1。
能够从ViewController1 -> NavigationController -> ViewController2移动
但无法后退,即ViewController1 <- NavigationController <- ViewController2
提前致谢。
解决方案
尝试任何一个
navigationController?.popViewController(animated: true)
dismiss(animated: true, completion: nil)
推荐阅读
- go - 在每个 BookName 之后的 booksName 数组中添加分号,如何将最后一个分号更改为 (And)
- javascript - 具有相同名称的函数 param 和 let/const 会引发错误
- cron - cron 是否有 cron 语法的权威标准文档?
- mvvm - 如何在 xamarin 表单中实现可扩展的 ListView
- controls - 使用 IRremote Arduino ESP8266 进行未知编码
- node.js - 为什么串行端口写入不适用于 for 循环?
- sql - 如何在 postgesql 的连接表中复制一行?
- mysql - 在 oracle 中使用正确的连接可以解决问题
- svn - tortoisesvn 慢 Windows 10
- postgresql - 如何限制 postgres 中更新的行数