导航栏错误

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

我已经嵌入应用程序中的导航栏,一切正常,除非进入我以编程方式设置导航栏的视图(segue to settings,reset function)。

它只显示自定义导航栏,这是好的,但如果我实现自定义后退按钮,整个应用程序具有相同的导航栏和有问题的导航栏(现在它显示重置和设置按钮无处不在)。

有没有办法让导航栏仅自定义到该特定视图?

部分代码:

self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: UIBarMetrics.default)
    self.navigationController?.navigationBar.shadowImage = UIImage()

    //Add gesture to MainLabel
    let tapLabel: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(resetTime))
    tapLabel.delegate = self
    mainLabel.isUserInteractionEnabled = true
    mainLabel.addGestureRecognizer(tapLabel)

    //Add gesture to UINavigationBar title
    let tapTitle: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(resetTime))
    tapTitle.delegate = self
    self.navigationItem.titleView = resetLabel
    self.navigationItem.titleView?.isUserInteractionEnabled = true
    self.navigationItem.titleView?.addGestureRecognizer(tapTitle)
}
ios swift label uinavigationbar uinavigationitem
1个回答
0
投票

是的,你可以在viewController的viewDidDisappear上隐藏导航按钮,你需要自定义导航栏和viewDidAppear取消隐藏所需的按钮。

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