gpt4 book ai didi

Swift 4 推送 viewController 而不是 present

转载 作者:搜寻专家 更新时间:2023-11-01 06:58:45 25 4
gpt4 key购买 nike

我在通过推送显示 ViewController 时遇到问题。我有这段代码,可以很好地与礼物搭配使用。但我需要改变它来插入。我尝试使用 self.navigationController?.pushViewController(slideMenuController, animated: true) 但这对我不起作用。

func navToRecord() { 
let mainViewController = kMainStoryboard.instantiateViewController(withIdentifier: "NQTPrivateOfficeViewController") as! NQTPrivateOfficeViewController
let leftViewController = kMainStoryboard.instantiateViewController(withIdentifier: "NQTLeftViewController") as! NQTLeftViewController

let nc = odrexNavigation(rootViewController: mainViewController)

let slideMenuController = EVTSlideMenuController(mainViewController: nc, leftMenuViewController: leftViewController)
slideMenuController.automaticallyAdjustsScrollViewInsets = true
mainViewController.navigationItem.leftBarButtonItem = UIBarButtonItem(title: NSLocalizedString("Завершить", comment: "finishOdrex"), style: .plain, target: self, action: #selector(action))

self.present(slideMenuController, animated: true, completion: nil)

UIApplication.shared.keyWindow?.makeKeyAndVisible()
}

最佳答案

你可以试试

let nav = UINavigationController(rootViewController: self)
UIApplication.shared.keyWindow?.rootViewController = nav
nav.pushViewController(slideMenuController, animated: true)

顺便说一句,不要期待这一行

self.navigationController?.pushViewController(slideMenuController, animated: true) 

如果你执行它的 VC 没有包含在 navigationController 中,因为 self.navigationController? 将是 nil

关于Swift 4 推送 viewController 而不是 present,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51858761/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com