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.
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.
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.
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.
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With