The best option is to use buttonItem.enabled = NO to indicate that functionality is currently unavailable. In most cases, this should be the correct behavior.
However, if you intend to make it disappear, the best way would be to save the link to the panel button. Set the rightBarButtonItem parameter to nil when you want it to disappear and set it to the saved link when you want it to appear.
source share