Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7747597
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:34:12+00:00 2026-06-01T10:34:12+00:00

I created a toolbar in IB with several buttons. I would like to be

  • 0

I created a toolbar in IB with several buttons. 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).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T10:34:13+00:00Added an answer on June 1, 2026 at 10:34 am

    Save your button in a strong outlet (let’s call it myButton) and do this to add/remove it:

    // Get the reference to the current toolbar buttons
    NSMutableArray *toolbarButtons = [self.toolbarItems mutableCopy];
    
    // This is how you remove the button from the toolbar and animate it
    [toolbarButtons removeObject:self.myButton];
    [self setToolbarItems:toolbarButtons animated:YES];
    
    // This is how you add the button to the toolbar and animate it
    if (![toolbarButtons containsObject:self.myButton]) {
        // The following line adds the object to the end of the array.  
        // If you want to add the button somewhere else, use the `insertObject:atIndex:` 
        // method instead of the `addObject` method.
        [toolbarButtons addObject:self.myButton];
        [self setToolbarItems:toolbarButtons animated:YES];
    }
    

    Because it is stored in the outlet, you will keep a reference to it even when it isn’t on the toolbar.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new in iphone...i have created toolbar with Four buttons...code is show below...I
I have a toolbar with various image buttons, created in Interface Builder. I'd like
I created a simple class to hide the details of creating a toolbar in
I made a toolbar with two buttons on it. I then created two outlets
I have a dynamically created toolbar on a plain Win32 dialog. My buttons are
I created my website with jQuery mobile and I would like to build the
I have created a toolbar using Interface Builder. I have a number of buttons
I have created customized menu and toolbar in MS Excel. I wanted to show
I have created a toolbar that has buttons. Of the buttons 3 of them
I have created a view loading to it toolbar with few 7 buttons. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.