How to add a toolbar to the bottom of a UITableViewController in Storyboards?

| | August 10, 2015

In my UITableView that I have setup using Storyboards, I need to be able to add a tool bar that sticks to the bottom of the view, it should not scroll.

Unlike this question: LINK I don’t think I could add a TableView subview to a normal view and then just add a toolbar programmatically because I am using dynamic cells which seem a lot easier to integrate via Storyboards.

For now, this is what I am stuck with….
enter image description here

3 Responses to “How to add a toolbar to the bottom of a UITableViewController in Storyboards?”

  1. I used an intermediate View Controller with a Container view to the table. Add the toolbar view to the intermediate, and make it look however you want (use UIButtons instead of UIBarButtonItem).

    If you do this, have the container view stretch to the top of the screen and not the bottom of the nav bar or you’ll pull your hair out trying to get the scroll insets right.

    Some more details in a similar question http://stackoverflow.com/a/31878998/1042111

    1. Drag a UIViewController into Storyboard
    2. Drag a UIToolbar on top of the Storyboard’s contents.
    3. Drag a UITableView on top of the Storyboard’s contents.
    4. Link the tableview’s delegate and datasource to your source code.

    Although you won’t be able to use UITableViewController as your linking class step 4 will allow you to link it to a regular UIViewController.

    You’ll need something like this in the header though

    @interface MyViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>
    

    It’ll look something like this in your storyboard:

    enter image description here

  2. if you want show toolbar in one view controller which placed in some navigation controller.

    1. select view controller in storyboard
    2. in utilities, show “attribute inspector”. select “bottom bar” style.
    3. add bar button item
    4. add code in view controller, to show and hide toolbar:

    code:

    - (void)viewWillAppear:(BOOL)animated
    {
        [self.navigationController setToolbarHidden:NO animated:YES];
    }
    
    - (void)viewWillDisappear:(BOOL)animated
    {
        [self.navigationController setToolbarHidden:YES animated:YES];
    }
    

Leave a Reply