How to add a footer to a UITableView in Storyboard

52,058

Solution 1

You can just drag a view to the bottom area of the tableView. You'll see in the hierarchy that it will be a subview of the tableview. You can then drag subviews such as labels and buttons there, adjust the height, etc.

Solution 2

Very simple!. dbrajkovic solution but in a graphical way. Just add a view to the table view.That's all!. enter image description here

In that example the footer view (Disclaimer View) has two labels ( Llb Disclaimer Title and Lbl Disclaimer Content).

Solution 3

The above answer worked for me with one twist. I found I couldn't add a footer if the cells filled up the entire height of the table view. Removing a couple of cells allowed me to add the footer, after which I was able to add the cells back.

Share:
52,058

Related videos on Youtube

Jon Cox
Author by

Jon Cox

Check out my UK train times iPhone app: Railboard https://itunes.apple.com/us/app/railboard/id1278747705?ls=1&mt=8

Updated on July 08, 2022

Comments

  • Jon Cox
    Jon Cox almost 2 years

    I'm fairly new to iOS development.

    I want to add a footer to the table view in a UITableViewController. I've made the view I want to use as the footer graphically in Storyboard, however I can't work out how to hook it up as the footer to my table view.

    I can add a footer programmatically in UITableViewController's viewDidLoad method by assigning self.tableView.tableFooterView. But I've created my footer view in Storyboard, what is the best practice way of adding it as the footer to my table view?

  • John Brewer
    John Brewer over 11 years
    Note that you can only do this if you have more than 0 prototype cells specified. Otherwise, the dragged-in view always becomes the header. To fix this, change the number of prototype cells to 1, drag in the view underneath the one prototype cell, then change the number of prototype cells back to 0.
  • John
    John over 11 years
    Thanks for the answer. It saved me a day. I was working on adding an extra cell with Button on it, and was trapped with CoreData failure when updating the tableView. I didn't know that it could be done like this. Such an easy and clean solution for me.
  • Stas
    Stas about 11 years
    I've done exactly as described - added a view to footer, created the class for my footer view but when I try to connect outlets it fails! It just do not see the class where to add outlets (manual selection makes no use)
  • Chris Wagner
    Chris Wagner over 10 years
    If you're having trouble getting to dragged in view to be the footer view, add a header view and then try to add another view the same way you added the header view and it will set itself to the footer, then can delete the header.
  • bugloaf
    bugloaf about 10 years
    Or just stretch the scene's height so that the table view stretches higher.
  • Shaunti Fondrisi
    Shaunti Fondrisi about 10 years
    You can mouse wheel up and down within the editor. Like the view is actively scrolling.
  • Franco Solerio
    Franco Solerio about 9 years
    To stretch the tableview in interface builder, remember to set "Simulated Size" to "Freeform" in Size Inspector for the tableview scene.
  • sports
    sports almost 9 years
    Is this answer working today with Xcode 6 (2015)? My UITableView has one prototype cell and if I drag a button to the UITableView, it is hosted in the prototype cell instead of creating a footer view. If I drag the button to the Document Outline > Table View it doesn't work. The button is hosted at the same level of "First responder" or "Exit"
  • AsifHabib
    AsifHabib about 8 years
    I just dropped a view on UITableView. It is not showing at bottom. When I move that above the cell, it shows in the start of the Table. While below it is not showing at all. Any Reason why @JohnBrewer
  • micnguyen
    micnguyen over 7 years
    This is still working on XCode 7.3.1. Just make sure after you drag the view in after setting a prototype cell that you re-drag the view so that it's definitely visually below the cell and then turn off the cell. Once the cell is turned off, the view is the only child view of the tableview and even though it doesn't look like it, it definitely is the footer.
  • GatoCurioso
    GatoCurioso almost 7 years
    Wow, this is a great hint ;)
  • Ali
    Ali over 6 years
    Also make sure you have given trailing, leading, top bottom constraint to table view
  • Kiryl Bielašeŭski
    Kiryl Bielašeŭski over 6 years
    @JohnBrewer You may add your comment as answer. I think many people search this question, because they have a problem with dynamic cells and footer in the storyboard. It helped me. Thank you very much!
  • buguibu
    buguibu almost 5 years
    Alongside to that @JohnBrewer said, if there is no cell and you add a subview the first one will be the header and the second one the footer, so if you need just a footer add a zero height header and then the footer or manually edited the storyboard.
  • Tim Schmidt
    Tim Schmidt almost 5 years
    This appeared to work for me but the table view doesn't appear to be letting me scroll down to see all of my footer. For example, I created just a blank 500 height view but I can only scroll down to see about half of it. If I debug the view hierarchy in xcode, the view has the correct height of 500 but, as I said, only about half of it is visible. Anyone know why that would be?