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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:26:03+00:00 2026-05-22T22:26:03+00:00

I am trying this but it does not work. -(void)viewDidLoad { // create a

  • 0

I am trying this but it does not work.

-(void)viewDidLoad
{
    // create a toolbar where we can place some buttons
    UIToolbar* toolbar = [[UIToolbar alloc]
                    initWithFrame:CGRectMake(0, 0, 100, 45)];
    [toolbar setBarStyle: UIBarStyleBlackOpaque];

    // create an array for the buttons
    NSMutableArray* buttons = [[NSMutableArray alloc] initWithCapacity:3];

    // create a standard save button
    UIBarButtonItem *saveButton = [[UIBarButtonItem alloc]
        initWithBarButtonSystemItem:UIBarButtonSystemItemSave
        target:self
        action:@selector(saveAction:)];
    saveButton.style = UIBarButtonItemStyleBordered;
    [buttons addObject:saveButton];
    [saveButton release];

    // create a spacer between the buttons
    UIBarButtonItem *spacer = [[UIBarButtonItem alloc]
        initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace
        target:nil
        action:nil];
    [buttons addObject:spacer];
    [spacer release];

    // create a standard delete button with the trash icon
    UIBarButtonItem *deleteButton = [[UIBarButtonItem alloc]
        initWithBarButtonSystemItem:UIBarButtonSystemItemTrash
        target:self
        action:@selector(deleteAction:)];
    deleteButton.style = UIBarButtonItemStyleBordered;
    [buttons addObject:deleteButton];
    [deleteButton release];

    // put the buttons in the toolbar and release them
    [toolbar setItems:buttons animated:NO];
    [buttons release];

    // place the toolbar into the navigation bar
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]
            initWithCustomView:toolbar];
    [toolbar release];
}

How can I solve this?

  • 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-22T22:26:04+00:00Added an answer on May 22, 2026 at 10:26 pm
    UIToolbar* toolbar = [[UIToolbar alloc]
                          initWithFrame:CGRectMake(0, 0, 320, 45)];
    [toolbar setBarStyle: UIBarStyleBlackOpaque];
    
    // create an array for the buttons
    NSMutableArray* buttons = [[NSMutableArray alloc] initWithCapacity:5];
    
    // create a standard save button
    UIBarButtonItem *saveButton = [[UIBarButtonItem alloc]
                                   initWithBarButtonSystemItem:UIBarButtonSystemItemSave
                                   target:self
                                   action:@selector(deleteAction:)];
    saveButton.style = UIBarButtonItemStyleBordered;
    [buttons addObject:saveButton];
    [saveButton release];
    
    // create a standard delete button with the trash icon
    UIBarButtonItem *deleteButton = [[UIBarButtonItem alloc]
                                     initWithBarButtonSystemItem:UIBarButtonSystemItemTrash
                                     target:self
                                     action:@selector(deleteAction:)];
    deleteButton.style = UIBarButtonItemStyleBordered;
    [buttons addObject:deleteButton];
    [deleteButton release];
    
    UIBarButtonItem *addbutton = [[UIBarButtonItem alloc]
                                     initWithBarButtonSystemItem:UIBarButtonSystemItemAdd
                                     target:self
                                     action:@selector(deleteAction:)];
    addbutton.style = UIBarButtonItemStyleBordered;
    [buttons addObject:addbutton];
    [addbutton release];
    
    UIBarButtonItem *editButton = [[UIBarButtonItem alloc]
                                  initWithBarButtonSystemItem:UIBarButtonSystemItemEdit
                                  target:self
                                  action:@selector(deleteAction:)];
    editButton.style = UIBarButtonItemStyleBordered;
    [buttons addObject:editButton];
    [editButton release];
    
    UIBarButtonItem *doneButton = [[UIBarButtonItem alloc]
                                   initWithBarButtonSystemItem:UIBarButtonSystemItemDone
                                   target:self
                                   action:@selector(deleteAction:)];
    doneButton.style = UIBarButtonItemStyleBordered;
    [buttons addObject:doneButton];
    [doneButton release];
    
    // put the buttons in the toolbar and release them
    [toolbar setItems:buttons animated:NO];
    [buttons release];
    
    // place the toolbar into the navigation bar
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:toolbar];
    [toolbar release];
    

    Try this code snippet

    And In AppDelegate.h file you declare this

    UINavigationController *navigationController; 
    

    And AppDelegate.m file

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
    
    // Override point for customization after application launch.
    
    // Add the view controller's view to the window and display.
    navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
    [self.window addSubview:navigationController.view];
    [self.window makeKeyAndVisible];
    
    return YES;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been trying this a couple of different ways, but it's not working for
I'm trying to test this out on my site but it doesn't quite work
I am trying to figure out why my delegate function does not work, any
Total newbie question but this is driving me mad! I'm trying this: myInt =
I've been trying this a few different ways, but I'm reaching the conclusion that
I am trying this in my Form Load Event cmdCancel.Attributes.Add(onClick, document.forms[0].reset();return false;) but it
Trying to do this sort of thing... WHERE username LIKE '%$str%' ...but using bound
I know very little about JavaScript but despite this I'm trying to cobble something
I'm trying to get this simple PowerShell script working, but I think something is
I'm trying to use this layout with two 50% column width instead. But it

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.