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 180781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T14:38:48+00:00 2026-05-11T14:38:48+00:00

in my app I have a toolbar and at a certain point I want

  • 0

in my app I have a toolbar and at a certain point I want to disable or enable some buttons. What is the easiest way to do so? How can I access items property of UIToolbar?

Here is my code:

-(void)addToolbar {     NSMutableArray *buttons = [[NSMutableArray alloc] init];       //Define space     UIBarButtonItem *flexibleSpaceItem;      flexibleSpaceItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem: UIBarButtonSystemItemFlexibleSpace target:nil action:NULL];       //Add 'new' button     UIBarButtonItem *newButton = [[UIBarButtonItem alloc]                                   initWithTitle:@'New' style:UIBarButtonItemStyleBordered target:self action:@selector(new_clicked)];     [buttons addObject:newButton];     [newButton release];      //Add space     [buttons addObject:flexibleSpaceItem];      //Add 'make active' button     UIBarButtonItem *activeButton = [[UIBarButtonItem alloc]                                   initWithTitle:@'Make Active' style:UIBarButtonItemStyleBordered target:self action:@selector(make_active_clicked)];     [buttons addObject:activeButton];     [activeButton release];      [buttons addObject:flexibleSpaceItem];      //Add 'edit' button     UIBarButtonItem *editButton = [[UIBarButtonItem alloc]                                   initWithTitle:@'Edit' style:UIBarButtonItemStyleBordered target:self action:@selector(edit_clicked)];     [buttons addObject:editButton];     [editButton release];      [flexibleSpaceItem release];      [toolBar setItems:buttons];     [buttons release]; } 

Thank you in advance.

  • 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. 2026-05-11T14:38:48+00:00Added an answer on May 11, 2026 at 2:38 pm

    The simplest way is to save a reference to the UIBarButtonItem as an instance variable.

    # header file UIBarButtonItem *editButton; 

    Then your code becomes

    # .m file editButton = [[UIBarButtonItem alloc]                initWithTitle:@'Edit'                style:UIBarButtonItemStyleBordered                target:self                action:@selector(edit_clicked)]; [buttons addObject:editbutton]; 

    Now anywhere in any instance method, disabling the button is as simple as:

    editButton.enabled = NO; 

    Also dont release it immediately, since this class now owns the button object. So release it in the dealloc method instead.

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

Sidebar

Related Questions

I have a navigation controller based app, and added some toolbar items with code
my app have action bar on top of windows. Where are some buttons. Buttons
I want to make a app where I need to have a toolbar. The
I have a rails app using a ul as a toolbar. I want to
I have an app that in a certain Activity (drawing) can be in any
I'm using EasyTracker google analytics library and my app have multiple activities. I want
I have a little app that have by default youtube as homepage. You can
I have app in which i have recorded sound files i want that i
In my app I have 3 UIPopOvers. They appear when user taps buttons in
App Description: I have a UIWebview and a Toolbar beneath it. A button on

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.