ios - SWRevealViewController 使用 swift 以编程方式从菜单中打开第二个视图控制器
问题描述
我在我的应用程序中使用 SWRevealViewController。一切都很好,除了一件事。
假设我的 SWRevealViewController 菜单中有 A、B、C 3 个项目。我想使用 swift 以编程方式打开 B 项。
更新:代码
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let sw = storyboard.instantiateViewController(withIdentifier: "Reveal") as! SWRevealViewController
let destinationController = storyboard.instantiateViewController(withIdentifier: "VehicleList") as! VehicleList
let navigationController = UINavigationController(rootViewController: destinationController)
sw.pushFrontViewController(navigationController, animated: true)
解决方案
这是我的问题的完整解决方案之二。
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let destinationController = storyboard.instantiateViewController(withIdentifier: "VehicleList") as! VehicleList
let navigationController = revealViewController().frontViewController as? UINavigationController
navigationController?.pushViewController(destinationController, animated: false)
推荐阅读
- c# - WordpressPCL 迭代检索到的帖子
- c - 指针变量在C中同时变化?
- xamarin.forms - 如何在android项目之外使用FormsAppCompatActivity
- excel - 更改 Access 表中的一个单元格
- html - 如何使用css在我的垂直导航栏中的联系人下添加底部边框?
- c++ - c++科学记数法,改变指数的位数
- python - 最长的字母子串不返回最后一个索引字符
- java - 如何在 Spring 项目中创建包含 main 方法的类的实例
- c# - 尝试围绕固定点旋转对象
- python-3.x - 安装 Tensorflow 2 在 pywrap_tensorflow.py 中加载 dll 失败