How do I hide/show the right button in the Navigation Bar

前端 未结 18 2008
后悔当初
后悔当初 2020-12-12 19:25

I need to hide the right button in the Navigation Bar, then unhide it after the user selects some options.

Unfortunately, the following doesn\'t work:



        
18条回答
  •  情话喂你
    2020-12-12 19:49

    Swift 2:

    Trick!

    Hide:

    if let btn = self.tabBarController!.navigationItem.rightBarButtonItem {
            btn.enabled = false
            btn.title = ""
    }
    

    Show:

    if let btn = self.tabBarController!.navigationItem.rightBarButtonItem {
            btn.enabled = true
            btn.title = "ButtonName"
    }
    

提交回复
热议问题