How can I make the footerview always stay at the bottom in UITableViewController?

27,934

Solution 1

The tableview footer view would always stay at the bottom of the tableview and would always scroll with it. 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.

Solution 2

A footer is always added to the bottom of the content size. So my approach is

Approach 1: (Available for Both Static and Dynamic TableView)

Add a ViewController in Storyboard and set your footer view(or button) at the bottom of the ViewController.

Add a ContainerView in the ViewController and set constraint

Add a UITableViewController and embedded the tableview in the container view

Approach 2: (Available for both Dynamic TableView)

Add a ViewController, set footer view in the bottom, add UITableView and set your auto layout.

You can't set static tableview in a UIViewController

Share:
27,934
Isha Balla
Author by

Isha Balla

Updated on December 08, 2021

Comments

  • Isha Balla
    Isha Balla over 2 years

    I am using a UITableviewcontroller and I want the footer view to always stay at the bottom of the screen. However, the y position of the footer view is changing as per the height of the tableviewcell. How can I always make it stick to the bottom of the screen?

  • Isha Balla
    Isha Balla over 8 years
    I know it sounds stupid. But is it possible to add another a view in tableviewcontroller? Here m working on something for which I have to use tableviewcontroller so can't switch to a view controller. I am trying to make it work :( is it possible to add any other view in tableviewcontroller class? And maybe make it stick to the bottom
  • user1107173
    user1107173 over 6 years
    If you are using a UINavigationController, you an add your footerview as a subview to your navigationController. Don't forget to remove the footerView from viewDidDisappear, otherwise it'll appear with all of your screens in the navigation stack.