Hiding UINavigationItem's bar button

后端 未结 11 1037
粉色の甜心
粉色の甜心 2021-01-04 07:04

I have added a BarButton item to the left of the nav.bar through Interface Builder and in the code I want this only to show in my table view\'s edi

11条回答
  •  庸人自扰
    2021-01-04 07:18

    func showOrHideButton() {
            isEnabled ? showButton() : hideButton()
        }
    
     func showButton() {
            navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .compose, target: self, action: #selector(action))
        }
    
        func hideButton() {
            navigationItem.leftBarButtonItem = nil
        }
    

提交回复
热议问题