Search code examples
iphoneobjective-cxcodeuinavigationcontrolleruitoolbar

NavigationController UIToolbar Change Items


I want to change the items in my UIToolbar by hiding the toolbar, changing the items (button, fixed space, etc), and revealing it again.

I currently have a button on my UIToolbar that, when pressed, hides the toolbar by calling [[self navigationController]setToolbarHidden:YES animated:YES];.

How can I set these items? Is it possible using interface builder or do I need to hard-code them in?


Solution

  • You can set new items for the toolbar this way:

    [toolbar setItems:<new_items_array> animated:YES];
    

    It will also animate the change so you may not need to hide and show it again, which is not a good UI practice in general.