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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T00:40:53+00:00 2026-05-22T00:40:53+00:00

I have opted to use a UITableViewController without a nib. I need a UIToolbar

  • 0

I have opted to use a UITableViewController without a nib. I need a UIToolbar at the bottom with two buttons. What is the simplest way of doing that?

P.S. I know that I can easily use a UIViewController and add a UITableView however I want things to look consistent across the app.

Can someone help?

I saw the following example and I am not sure on its validity:

(void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];

    //Initialize the toolbar 
    toolbar = [[UIToolbar alloc] init]; toolbar.barStyle = UIBarStyleDefault;

    //Set the toolbar to fit the width of the app. 
    [toolbar sizeToFit];

    //Caclulate the height of the toolbar 
    CGFloat toolbarHeight = [toolbar frame].size.height;

    //Get the bounds of the parent view 
    CGRect rootViewBounds = self.parentViewController.view.bounds;

    //Get the height of the parent view. 
    CGFloat rootViewHeight = CGRectGetHeight(rootViewBounds);

    //Get the width of the parent view, 
    CGFloat rootViewWidth = CGRectGetWidth(rootViewBounds);

    //Create a rectangle for the toolbar 
    CGRect rectArea = CGRectMake(0, rootViewHeight - toolbarHeight, rootViewWidth, toolbarHeight);

    //Reposition and resize the receiver 
    [toolbar setFrame:rectArea];

    //Create a button 
    UIBarButtonItem *infoButton = [[UIBarButtonItem alloc] initWithTitle:@"back"
                                                                   style:UIBarButtonItemStyleBordered 
                                                                  target:self 
                                                                  action:@selector(info_clicked:)];

    [toolbar setItems:[NSArray arrayWithObjects:infoButton,nil]];

    //Add the toolbar as a subview to the navigation controller.
    [self.navigationController.view addSubview:toolbar];

    [[self tableView] reloadData];
}

(void) info_clicked:(id)sender {

    [self.navigationController popViewControllerAnimated:YES];
    [toolbar removeFromSuperview];

}
  • 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-22T00:40:53+00:00Added an answer on May 22, 2026 at 12:40 am

    The simpler thing to do is to build your project on top of a UINavigationController. It already has a toolbar, it’s just hidden by default. You can reveal it by toggling the toolbarHidden property, and your table view controller will be able to use it as long as it’s in the navigation controller hierarchy.

    In your app delegate, or in the object your app delegate passes control to, create the navigation controller with your UITableViewController as the root view controller:

    - ( void )application: (UIApplication *)application
              didFinishLaunchingWithOptions: (NSDictionary *)options
    {
        MyTableViewController         *tableViewController;
        UINavigationController        *navController;
    
        tableViewController = [[ MyTableViewController alloc ]
                                     initWithStyle: UITableViewStylePlain ];
        navController = [[ UINavigationController alloc ]
                               initWithRootViewController: tableViewController ];
        [ tableViewController release ];
    
        /* ensure that the toolbar is visible */
        navController.toolbarHidden = NO;
        self.navigationController = navController;
        [ navController release ];
    
        [ self.window addSubview: self.navigationController.view ];
        [ self.window makeKeyAndVisible ];
    }
    

    Then set the toolbar items in your MyTableViewController object:

    - ( void )viewDidLoad
    {
        UIBarButtonItem            *buttonItem;
    
        buttonItem = [[ UIBarButtonItem alloc ] initWithTitle: @"Back"
                                                style: UIBarButtonItemStyleBordered
                                                target: self
                                                action: @selector( goBack: ) ];
        self.toolbarItems = [ NSArray arrayWithObject: buttonItem ];
        [ buttonItem release ];
    
        /* ... additional setup ... */
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am building a web application and have opted to use similar table and
I've never been much to use C++ I/O streams and have always opted for
I am currently working on a project and have opted to use Habanero as
In a project I have taken on, the original author has opted to use
I think I finally figured out they need to use this DeclarativeFieldsMetaclass (to turn
Have noticed issue while testing iphone app that if one quickly opens/dismisses a modal
I have a project that adds elements to an AutoCad drawing. I noticed that
I have a script that appends some rows to a table. One of the
I have a new web app that is packaged as a WAR as part
i have a input tag which is non editable, but some times i need

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.