【问题标题】:SWRevealViewController hiding navigationbar for my front view controllerSWRevealViewController 隐藏我的前视图控制器的导航栏
【发布时间】:2019-05-26 07:21:00
【问题描述】:

我有具有后视图和前视图的 Reveal View 控制器,后视图是我的侧边菜单,问题是当我从侧边菜单中点击菜单项时,它显示目标视图控制器但导航栏未显示。请帮我。我是iOS新手。 这是我的故事板图片: https://imgur.com/a/PbDygKO

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    itemIndex = indexPath.row
    self.revealViewController().revealToggle(animated: true)
    performSegue(withIdentifier: "webview", sender: nil)
}

这里是准备功能

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    guard let navigationController = segue.destination as? UINavigationController, let progressWebViewController = navigationController.topViewController as? ProgressWebViewController else {
        return
    }

    switch itemIndex {
    case 1:
        let storyBoard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
        let newViewController = storyBoard.instantiateViewController(withIdentifier: "aboutus") as! AboutUsController
        self.present(newViewController, animated: true, completion: nil)
        break

    case 2:
        loadURL(progressWebViewController: progressWebViewController ,url: "https://google.com", title: "Event Planning")

    case 3:
        loadURL(progressWebViewController: progressWebViewController ,url: "https://google.com", title: "NCC Checklist")

    default:
        print("Unknown segue \(itemIndex)")
    }
}

【问题讨论】:

    标签: ios swift navigationbar


    【解决方案1】:

    是因为这行: self.present(newViewController, animated: true, completion: nil)

    当你展示一个 viewController 时,它有一个模态行为并且没有navigationController

    所以如果你需要 navigationController ,你应该使用 pushViewController 来代替

    像这样:self.navigationController.pushViewController(newViewController, animated: true)

    【讨论】:

      猜你喜欢
      • 2015-11-14
      • 2018-04-19
      • 2015-07-17
      • 2015-02-13
      • 2016-04-10
      • 2017-02-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多