Reputation: 1221
I want to add a footer to the UITableView, there are two ways, either footer for the section, or footer for the UITableView. Both don't work for me because I want to footer always at the bottom of the screen. In other words, floating footer.
That's why after searching, people suggest to but the footer under the UITableView. I would need to resize the UITableView and add the footer through IB under it. That makes sense and that's what I am asking for.
Kindly I have a specific problem and It's not about footer at all
My problem is that I couldn't create constrains for the UITableView that locates inside UITableViewContoller, whenever I click Ctrl
+ drag, I don't see the options that I would normally see.
Is that because I'm working with UITableViewController?
This is a screenshot of my hirechy
Again I would like to resay that my problem is not about footers, my problem is about how to resize the UITableView in a UITableViewController
Upvotes: 2
Views: 1065
Reputation: 38833
I created a sample project with a fixed footer. You can download it here. What I have added is:
ContainerView
100%
- TableView
90% of the ContainerView
and constraints to the ContainerView
- View
10% of the ContainerView
and constraints to the ContainerView
Upvotes: 4
Reputation: 386
Yes, you are correct. You cannot add a footer on a UITableViewController. For this I recommend using a UIViewController.
Follow these steps if you want to add a footer:
Also for the controller, just create two classes within the same file, and make one of them as a UITableViewController and the footer as regular class within the file.
If you just want space you should just use UIViewController. Add UITableView inside that, and put constraints on that.
This is one approach, and there maybe many other. Please let me know if I can help you any further.
Upvotes: 1
Reputation: 3896
You shouldn't resize the UITableView
of an UITableViewController
object : your tableview is in fact your main view.
If you want to put a empty space that can't be scrolled below an UITableView
, you should use an UIViewController
instead.
Add an UITableView
and an UIView
to this UIViewController
object.
Set the left, right, and bottom constraints aligned to its superview for the UIView
, and fix its height with a fourth constraint. Add the left, right and top constraints aligned to its superview for the UITableView
, and set the vertical space between the view and the tableview to 0 with a constraint.
Upvotes: 1