iOS Swift导航标题未显示

问题描述 投票:0回答:1

我有一个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"
    }

}

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

Output

ios swift uinavigationcontroller uitabbarcontroller
1个回答
0
投票

确保您的拳头控制器是嵌入导航控制器的拳头,然后您的所有控制器都与导航栏相连

喜欢这样

enter image description here

然后通过单独的navigController将导航控制器嵌入到每个视图控制器中>

© www.soinside.com 2019 - 2024. All rights reserved.