【问题标题】:iOS Swift navigation title is not showing upiOS Swift 导航标题未显示
【发布时间】:2020-03-15 05:43:33
【问题描述】:

我有一个 tabBarController,我在它下面加载了一些导航控制器。但是我的导航控制器的标题没有出现。即使我注意到如果我在左右导航栏项目中添加按钮,它也不会显示出来。

我的标签栏设置:

let quranNavigationController = UINavigationController()

//        quranNavigationController.navigationBar.titleTextAttributes = textAttributes
//        quranNavigationController.navigationBar.tintColor = Colors.primaryTextColor
//        quranNavigationController.navigationBar.barTintColor = Colors.navigationBackgroundPrimary

let quranSnackBarController = AppSnackbarController(rootViewController: quranNavigationController)
quranSnackBarController.shouldExtend = false
quranSnackBarController.tabBarItem = UITabBarItem(title: "Books".localized(), image: UIImage(named: "quran"), tag: 1);

let menuViewController = TestViewController()
let quranController = QuranPrintController()
let sideMenuController = SideMenuController(contentViewController: quranController, menuViewController: menuViewController)
quranNavigationController.viewControllers = [sideMenuController]

tabBarController.viewControllers = [homeNavigationController2, quranSnackBarController, prayerNavigationController, duaSnackBarController]
window.rootViewController = tabBarController

QuranPrintController:

class QuranPrintController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        self.title = "Quran"
        self.navigationItem.title = "Prayer Times"
    }

}

这就是我的输出。没有显示标题。我尝试在左侧和右侧添加按钮。但效果不佳

【问题讨论】:

  • 你是如何设置 rootViewController 的?

标签: ios swift uinavigationcontroller uitabbarcontroller


【解决方案1】:

首先确保您的 tabbarcontroller 嵌入了导航控制器,然后您的所有控制器都与您的导航栏连接

喜欢这个

然后将您的导航控制器嵌入到您的每个视图控制器中,并使用单独的 navigController

【讨论】:

    【解决方案2】:

    尝试将其添加到您的 ViewdidLoad() 中。

        self.view.bringSubviewToFront(yourbuttonname)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-23
      相关资源
      最近更新 更多