Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a footer to a UITableView in Storyboard

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?

like image 908
Jon Cox Avatar asked Mar 07 '12 16:03

Jon Cox


People also ask

How can I make the Footerview always stay at the bottom in Uitableviewcontroller?

If you need to make the footer view fixed at the bottom then you can not use a TableViewController . You will have to use UIViewController , put your tableView as a subview. Put the footer also as another subview and its done.


3 Answers

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.

like image 187
dbrajkovic Avatar answered Oct 07 '22 22:10

dbrajkovic


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).

like image 30
Javier Calatrava Llavería Avatar answered Oct 07 '22 23:10

Javier Calatrava Llavería


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.

like image 24
timschmitz Avatar answered Oct 08 '22 00:10

timschmitz