在viewDidLoad中,我使用以下命令配置navigationBar:
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
}
}
当我想向右滑动回到前一个控制器并中断时,显示蓝色色调的Back按钮。 那么,为什么它会显示以及如何禁用它?
答案 0 :(得分:0)
我在当前视图控制器的viewDidAppear中添加了一行代码来解决此问题。
self.navigationController?.navigationBar.backItem?.backBarButtonItem = nil