如何顯示/隱藏 UIBarButtonItem? - How do I show/hide a UIBarButtonItem?

問題:

I created a toolbar in IB with several buttons.我在 IB 中創建了一個帶有幾個按鈕的工具欄。 I would like to be able to hide/show one of the buttons depending on the state of the data in the main window.我希望能夠根據主窗口中的數據狀態隱藏/顯示按鈕之一。

UIBarButtonItem doesn't have a hidden property, and any examples I've found so far for hiding them involve setting nav bar buttons to nil, which I don't think I want to do here because I may need to show the button again (not to mention that, if I connect my button to an IBOutlet, if I set that to nil I'm not sure how I'd get it back). UIBarButtonItem沒有隱藏屬性,到目前爲止我發現的任何隱藏它們的示例都涉及將導航欄按鈕設置爲零,我認爲我不想在這裏這樣做,因爲我可能需要再次顯示按鈕(更不用說,如果我將我的按鈕連接到 IBOutlet,如果我將其設置爲 nil,我不確定如何將其取回)。


解決方案:

參考一: https://en.stackoom.com/question/g376
參考二: https://stackoom.com/question/g376
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章