【问题标题】:Navigation bar error导航栏错误
【发布时间】:2017-12-29 17:42:15
【问题描述】:

我已在应用程序的导航栏中嵌入,一切正常,除了进入我以编程方式设置导航栏的视图时(转到设置,重置功能)。

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

有没有办法让导航栏只针对该特定视图进行自定义?

部分代码:

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】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-02-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多