首页 > 解决方案 > 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)

标签: iosswiftxcodeswrevealviewcontroller

解决方案


这是我的问题的完整解决方案之二。

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)

推荐阅读