【问题标题】:UINavigationBar show Back button after interrupt swiping right from left edge gesture, how to hide it and why it shown?UINavigationBar 在中断从左边缘手势向右滑动后显示返回按钮,如何隐藏它以及为什么显示它?
【发布时间】:2016-03-25 04:24:22
【问题描述】:

在 viewDidLoad 中,我将导航栏配置为:

self.navigationController?.setNavigationBarHidden(false, animated: true)
self.navigationItem.setHidesBackButton(true, animated: false)

let backButton:UIBarButtonItem = UIBarButtonItem(image: UIImage(named: "nav_back_normal"), style: UIBarButtonItemStyle.Done, target: self, action: #selector(ProfileViewController.backTapped(_:)))

self.navigationItem.setLeftBarButtonItems([backButton], animated: true)

在之前的视图控制器的 viewDidAppear 中,

self.navigationController?.navigationBarHidden = true
self.navigationController?.interactivePopGestureRecognizer?.delegate = self

手势代表是:

func gestureRecognizerShouldBegin(gestureRecognizer: UIGestureRecognizer) -> Bool {
    if self.navigationController?.viewControllers.count > 1 {
        return true
    }else {
        return false
    }
}

当我想向右滑动回到前一个控制器并中断时,会显示蓝色的后退按钮。 那么,为什么会显示以及如何禁用它?

【问题讨论】:

    标签: ios uinavigationbar


    【解决方案1】:

    我在当前视图控制器的 viewDidAppear 中添加了一行代码来解决这个问题。

            self.navigationController?.navigationBar.backItem?.backBarButtonItem = nil
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-05-28
      • 2016-07-23
      • 2014-01-14
      • 2013-03-15
      • 1970-01-01
      • 1970-01-01
      • 2017-03-20
      • 1970-01-01
      相关资源
      最近更新 更多