UINavigationController Interactive Pop Gesture Not Working?

前端 未结 10 1463
你的背包
你的背包 2020-12-13 10:02

So I have a navigation controller in my built for iOS 7 app. The titleView is visible, as well as the back button and navigation bar its self. For some reason, the interac

10条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-13 10:31

    Maybe someone may find this helpful.

    If you want to hide the navigation bar but use normal swipe gestures to go back and other navigation controller features, you should use: (navigationBar)

    self.navigationController?.navigationBar.isHidden = true
    

    If you want to disable navigation bar (hide navigation bar, disable swipe for back) but want to push viewcontroller you should use: (isNavigationBarHidden)

    self.navigationController?.isNavigationBarHidden = true
    

    Update 7-DEC-2018:

    Recommended way:

    In case that your first controller use hidden navigation bar, but next childs use navigation bar, when you come back to base view controller you will see a black bar in transition in place of navigation bar. This will be fixed very easy if you use in first viewcontroller(father):

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        self.navigationController?.setNavigationBarHidden(true, animated: animated)
    }
    
    override func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(animated)
        self.navigationController?.setNavigationBarHidden(false, animated: animated)
    }
    

提交回复
热议问题