与UINavigationController斗争

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

由于UINavigationController拒绝显示任何标题,甚至拒绝显示titleView,BackItem?.title,所有内容都无法正常工作,我一直在苦苦挣扎。我可以在顶部看到导航栏,只是空白。这是我的代码:

class tab1_main: UIViewController {
    var main_nav_controller = UINavigationController()
    override func viewDidLoad() {
        main_nav_controller.navigationBar.backItem?.title = "Hello" //NO LUCK
        main_nav_controller.navigationBar.topItem?.title = "Hello" //NO LUCK
        main_nav_controller.title = "Hello" //NO LUCK
        self.title = "Hello" //NO LUCK
        navigationItem.title = "Hello" //NO LUCK

        view.addSubview(main_nav_controller.view)
        tab1_startup()
    }
}
ios swift navigation uinavigationcontroller uinavigationbar
1个回答
0
投票

你去。 :)我希望它会有所帮助。

// Set up the title
self.navigationItem.title = "Title"
/// if you want to use large title then set true to use large title into small title if scroll down.
self.navigationController?.navigationBar.prefersLargeTitles = true
© www.soinside.com 2019 - 2024. All rights reserved.