【问题标题】:When i pop controller i get black screen?当我弹出控制器时,我得到黑屏?
【发布时间】:2018-11-01 02:51:57
【问题描述】:

(我需要当前的 vc 而不是推送 vc)

我有一个标签栏和一个导航控制器界面

我的第一个标签栏项目 vc1 和第二个标签栏项目是 vc2

push vc 工作正常,这就是我所做的 第 1 步-我单击 vc1 中的一个按钮,该按钮通过导航推送将我导航到 vc3

接下来我点击了 vc2 选项卡项 然后我点击 vc1 标签项和 然后我按下 vc3 的 BACK 按钮,我得到的是正确的应用程序流程

后退按钮弹出视图控制器

   fileprivate func presentDetail(at indexPath: IndexPath) {
        self.updateCell(at: indexPath)
        self.startLoading()
      let vc3 = storyboard?.instantiateViewController(withIdentifier: "vc3") as! vc3
            //   self.navigationController?.setViewControllers([vc,vc1], animated: true)

            vc3.modalPresentationStyle = .overCurrentContext
        vc3.data = mDataSource.shared.demoData[indexPath.row]
          if let navigator = navigationController {
            navigator.pushViewController(vc3, animated: true)
}

  @IBAction func backBtnTapped(_ sender: Any) {
        self.navigationController?.popViewController(animated: true)
       // performSegue(withIdentifier: "unwindSegueToVC1", sender: self)
    }

如何让目前的 VC 工作

  let vc = storyboard.instantiateViewController(withIdentifier: "vc3") as! vc3

       vc3.modalPresentationStyle = .overCurrentContext
            vc3.data = mDataSource.shared.demoData[indexPath.row]
 self.present(vc, animated: true, completion: nil)

【问题讨论】:

    标签: ios uinavigationcontroller uitabbarcontroller swift4


    【解决方案1】:

    您是否尝试删除此行?

    vc3.modalPresentationStyle = .overCurrentContext
    

    仅当您要呈现视图时才需要此行。

    【讨论】:

    • 非常抱歉,我打错了问题,让我编辑它。实际上它可以正常工作,我想知道是否有让它适用于当前的 vc,因为当前的 vc 会给我空白屏幕... ..请阅读我编辑的问题
    【解决方案2】:
    fileprivate func presentDetail(at indexPath: IndexPath) {
    
        self.updateCell(at: indexPath)
        self.startLoading()
    
        let vc3 = storyboard?.instantiateViewController(withIdentifier: "vc3") as! vc3
        self.hidesBottomBarWhenPushed = true //Use this line so you can hide tabbar. when you push to vc3 screen
        self.navigationController?.pushViewController(vc3, animated: true)
    
    }
    
    @IBAction func backBtnTapped(_ sender: Any) {
        self.navigationController?.popViewController(animated: true)
    }
    

    【讨论】:

      猜你喜欢
      • 2018-06-17
      • 2016-08-04
      • 2015-06-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-06
      • 1970-01-01
      相关资源
      最近更新 更多