【问题标题】:NavigationController PushedView Controller dismisses entire NavigationController - swift - ProgrammaticallyNavigationController PushedView 控制器关闭整个 NavigationController - swift - 以编程方式
【发布时间】:2020-09-29 00:19:32
【问题描述】:

我正在像这样模态地展示一个 NavigationController:

let profileViewController = ProfileViewController(nibName: nil, bundle: nil)
        let navigationControllerProfile = UINavigationController(rootViewController: profileViewController)
        navigationControllerProfile.setNavigationBarHidden(true, animated: false)
        navigationControllerProfile.modalPresentationStyle = .fullScreen
        self.present(navigationControllerProfile, animated: true, completion: nil)

每当我从这个 NavigationController 推送 Viewcontroller 时:

let showCaseViewController = ShowcaseViewController()
        showCaseViewController.modalPresentationStyle = .overFullScreen
        self.navigationController?.pushViewController(showCaseViewController, animated: true)

ViewController 被正确推送,但 1 秒后整个 NavigationController 被关闭。

【问题讨论】:

  • 添加完整代码...
  • 什么的完整代码?
  • 我在下面发了代码试试

标签: swift uiviewcontroller presentmodalviewcontroller navigationcontroller


【解决方案1】:

显示带有导航的视图控制器的代码

                let vc = storyboard?.instantiateViewController(withIdentifier: "firstvc") as! firstvc
                let navigation = UINavigationController(rootViewController: vc)
                vc.modalPresentationStyle = .fullScreen
                self.present(navigation, animated: true, completion: nil)

在呈现的视图控制器中执行推送操作的代码

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

【讨论】:

  • 我以编程方式呈现 ViewController 而不是故事板
猜你喜欢
  • 2015-05-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-12-02
  • 1970-01-01
  • 2018-11-18
相关资源
最近更新 更多