Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tableFooterView property doesn't fix the footer at the bottom of the table view

I am setting a footer view in the viewDidLoad method:

UIView *fView = [[UIView alloc] initWithFrame:CGRectMake(0, 718, 239, 50)]; fView.backgroundColor =[UIColor yellowColor]; self.table.tableFooterView = fView; 

Unfortunately, the footer is not drawing in the specified (x,y) specified above, but it stick with the cells, so if the table view has 4 cells, the footer will be drawn in the 5th cell.

I even tried the protocol method, tableView:viewForFooterInSection

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{  UIView *fView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 239, 50)]; fView.backgroundColor =[UIColor yellowColor];     return fView; } 

the problem is not resolved, I am sure tableFooterView property should fi the footer view at the bottom of the table view but I am not sure what I may be missing here? Thanx in advance.

like image 999
Malloc Avatar asked Mar 28 '13 16:03

Malloc


People also ask

How do I stick the footer to the bottom in Swift?

Make Footer Sticky To make your footer stick to the bottom of the viewport, add classes d-flex , flex-column , and h-100 to the body tag. Also add class h-100 to <html> tag.

How do I add a footer to a table view?

To only have a footer view, you will need to add a prototype cell, that will allow you to add a footer view below the cell. Let's add a footer now, again, we just need to drag a new view onto the table view, but this time place it below the other view.

How to add header and footer in tableView in swift?

To create a basic header or footer with a text label, override the tableView(_:titleForHeaderInSection:) or tableView(_:titleForFooterInSection:) method of your table's data source object. The table view creates a standard header or footer for you and inserts it into the table at the specified location.


1 Answers

Since your goal is to have a footer that stays fixed at the bottom of the screen, and not scroll with the table, then you can't use a table view footer. In fact, you can't even use a UITableViewController.

You must implement your view controller as a UIViewController. Then you add your own table view as a subview. You also add your footer as a subview of the view controller's view, not the table view. Make sure you size the table view so its bottom is at the top of the footer view.

You will need to make your view controller conform to the UITableViewDataSource and UITableViewDelegate protocols and hook everything up to replicate the functionality of UITableViewController.

like image 68
rmaddy Avatar answered Sep 18 '22 07:09

rmaddy