2

I need to display some footer text on an existing UITableView (ie. footer scrolls with table):

  1. the footer need to be at bottom of the screen if cells and footer can fit in one screen
  2. if remaining space on the screen can't fit the footer, footer need to start on another screen (ie. only visible when user scrolls down), so there's no half visible footer with cells when screen appears.

Case 1:

+-------------------+
|                   |
|CELL1              |
|                   |
|CELL2              |
|                   |
|LAST CELL          |
|                   |
|                   |
|                   |
|                   |
|FOOTER             |
|TEXT               |
|HERE               |
+-------------------+

Case 2:

+-------------------+
|                   |
|CELL1              |
|                   |
|CELL2              |
|                   |
|CELL3              |
|                   |
|CELL4              |
|                   |
|CELL5              |
|                   |
|CELL6              |
|                   |
|LAST CELL          |
|                   |
|                   |
+-------------------+
 FOOTER
 TEXT
 HERE

(notice there is still some space below LAST CELL, but it's not enough to make footer text fully visible, so footer need to go beyond table view's bounds)

I thought I could check table view's content size and compare it with its bounds to figure out available spaces, and have a spacer view in the footer view, which occupies:

  1. available space - footer size, if footer can fit into one screen as cells, or, if there's no enough space:
  2. available space

Then I could have the footer text label pinned to the bottom of the spacer view, however, when is the best place I could check for footer text's size? Is there a better way of doing this using auto-layout?

Thanks!

Heuristic
  • 5,087
  • 9
  • 54
  • 94

0 Answers0