ios - SWRevealViewController 为我的前 View Controller 隐藏导航栏

标签 ios swift navigationbar

我有 Reveal View Controller ,它有后 View 和前 View ,后 View 是我的侧面菜单,问题是当我点击侧面菜单中的菜单项时,它显示目标 View Controller ,但导航栏未显示。请帮我。我是 iOS 新手。 这是我的 Storyboard图片: 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)")
    }
}

最佳答案

这是因为这一行: self.present(newViewController,动画:true,完成:nil)

当你呈现一个 viewController 时,它具有模态行为并且没有 navigationController

因此,如果您需要 navigationController,则应该使用 pushViewController

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

关于ios - SWRevealViewController 为我的前 View Controller 隐藏导航栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56311490/

相关文章:

ios - CoreData - 我什么时候保存?

iOS - 在图像上绘画 - 应用蒙版

ios - 如何使用 AppDelegate 在 View 之间共享 iAd 横幅

ios - 点击按钮取消 AWSS3 TransferUtility 上传任务

css - 如何修复此导航菜单 - 它不会显示

android 将工具栏扩展为半透明状态栏,同时将其他布局对象保留在系统 View 中

iOS/Swift/Parse - 结构不存储数据

iphone - 内部分发 - ios sdk

ios - 如何正确缩放和定位 View

navigationbar - 在应用程序运行时以编程方式隐藏导航栏