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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:21:22+00:00 2026-05-24T23:21:22+00:00

I have added the toolbar using Interface Builder, but I need to add the

  • 0

I have added the toolbar using Interface Builder, but I need to add the buttons at runtime / conditionally. I’m not getting any errors, but my dynamic buttons are not appearing on the toolbar. I have verified that arrayOfModulesScreens is loaded with the data I need. At least that works (:)). Do I need to add the buttons into a UIView, then add that view to the toolbar? Just thinking outloud. Perhaps there is a better approach to begin with? Thanks in advance for any clues leading to the resolve.

CustomFormController.h

@interface CustomFormController : UIViewController { 
    UIToolbar *screensBar;  
}

CustomFormController.m

EPData *epData = [[EPData alloc] init];
NSArray *screens = [epData loadPlistIntoArray:@"Screens"];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"process_module_id == %@", process_modulesID];
NSArray *arrayOfModulesScreens = [screens filteredArrayUsingPredicate:predicate];

for(int i=0; i < [arrayOfModulesScreens count]; i++) {
    NSDictionary *dictRow = [arrayOfModulesScreens objectAtIndex:i];
    UIButton *button = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain];
    [button setTitle:[dictRow objectForKey:@"screen_title"] forState:UIControlStateNormal];
    [button addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
    [screensBar addSubview:button];  
}
  • 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-05-24T23:21:22+00:00Added an answer on May 24, 2026 at 11:21 pm

    If you are actually wanting to add a UIBarButtonItem (not a UIButton) to the toolbar, you just create one or more UIBarButtonItems, put them in an NSArray (or NSMutableArray), and assign that array to the items property of the toolbar. See the UIBarButtonItem documentation for details. Using your code above, that might look something like this:

        NSMutableArray *items = [NSMutableArray array];
        for (int i = 0; i < [arrayOfModulesScreens count]; i++) {
            NSDictionary *dictRow = [arrayOfModulesScreens objectAtIndex:i];
            UIBarButtonItem *button = [[UIBarButtonItem alloc] initWithTitle:[dictRow objectForKey:@"screen_title"]
                                                                       style:UIBarButtonItemStyleBordered
                                                                      target:self
                                                                      action:@selector(buttonClick:)];
            [items addObject:button];
            [button release];
        }
        screensBar.items = items;
    

    (you would, of course, then need to change your buttonClick: to expect a UIBarButtonItem instead of a UIButton).

    If you’re really wanting to put a UIButton in there, you first need to wrap the UIButton in a UIBarButtonItem, something like this:

    UIBarButtonItem *item = [[[UIBarButtonItem alloc] initWithCustomView:button] autorelease];
    

    Then add the item to the toolbar as above.


    As for why your buttons aren’t showing up in your posted code, the problem is that UIButton’s buttonWithType: creates a button with zero width and zero height. You would need to resize the button (manually or by using sizeToFit after setting the title) to make it show. After fixing that, you would then see that the buttons are all on top of each other in the upper-left corner of the parent view; you would need to position them manually as appropriate.

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

Sidebar

Related Questions

I have added multi-language using the short article below. When you add for example
I have added an EventHandler for the Click-event to a picturebox but on runtime
I have added a RadControl, RadGrid and I need to add a radComboBox in
I have added a MKUserTrackingBarButtonItem to my toolbar. But, clicking it does nothing. So,
I have added the required assemblies and registered the NVelocityViewFactory in global.asax.cs page but
I have added some dynamic textboxes upon a button click. I need the values
I have added some settings to my c# application using the configuration editor. There
I have a page with a toolbar on it, that is added through apply
I have a dynamically created toolbar on a plain Win32 dialog. My buttons are
I am dynamically added a bunch of buttons to a toolbar. I want the

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.